changeset 111573:e89dd9c3633b

merge trunk
author Kenichi Handa <handa@m17n.org>
date Mon, 08 Nov 2010 14:19:54 +0900
parents b3f9490f0b7f (current diff) b527d5f89f7f (diff)
children a92967e45167
files lib-src/digest-doc.c lib-src/sorted-doc.c nextstep/AUTHORS
diffstat 387 files changed, 16205 insertions(+), 11667 deletions(-) [+]
line wrap: on
line diff
--- a/BUGS	Mon Nov 08 14:19:24 2010 +0900
+++ b/BUGS	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/ChangeLog	Mon Nov 08 14:19:54 2010 +0900
@@ -1,3 +1,46 @@
+2010-11-06  Andreas Schwab  <schwab@linux-m68k.org>
+
+	* configure.in: Fix indentation.
+
+2010-10-31  Ken Brown  <kbrown@cornell.edu>
+
+	* configure.in (checking whether localtime caches TZ): Use
+	unsetenv instead of modifying environment directly.
+
+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	Mon Nov 08 14:19:24 2010 +0900
+++ b/INSTALL	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/INSTALL.BZR	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/README	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/admin/make-tarball.txt	Mon Nov 08 14:19:54 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/admin/notes/bugtracker	Mon Nov 08 14:19:24 2010 +0900
+++ b/admin/notes/bugtracker	Mon Nov 08 14:19:54 2010 +0900
@@ -384,6 +384,14 @@
 *** To remove a "fixed" mark:
 notfixed 123 23.0.60
 
+*** To make a bug as present in a particular version:
+found 123 23.2
+NB if there is no specified "fixed" version, or if there is one and it
+is earlier than the found version, this reopens a closed bug.
+
+The leading "23.1;" that M-x report-emacs-bug adds to bug subjects
+automatically sets a found version (if none is explicitly specified).
+
 *** To assign or reassign a bug to a package or list of packages:
 reassign 1234 emacs
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/admin/notes/elpa	Mon Nov 08 14:19:54 2010 +0900
@@ -0,0 +1,42 @@
+NOTES ON THE EMACS PACKAGE ARCHIVE
+
+Here are instructions on uploading files to the package archive at
+elpa.gnu.org, for Emacs maintainers.  (If you are not a maintainer,
+contact us if you want to submit a package.)
+
+1. You will need login access to elpa.gnu.org.  You will also need to
+   get the FSF sysadmins to allow ssh access through the FSF firewall
+   for your local machine.  Ensure that your uid, USER, is in the
+   `elpa' group on elpa.gnu.org; this gives you write access to the
+   bzr repository from which the packages are managed.
+
+2. Go to your bzr repository on your local machine.  Of, if you don't
+   have one (you should, if you're tracking Emacs bzr), make one:
+
+     cd $DEVHOME
+     bzr init-repo elpa/
+     cd elpa
+
+   Create a branch for elpa:
+
+     bzr branch bzr+ssh://USER@elpa.gnu.org/home/elpa/package-repo package-repo
+
+   Bind the branch:
+
+     cd package-repo/
+     echo "public_branch = bzr+ssh://USER@elpa.gnu.org/home/elpa/package-repo" >> .bzr/branch/branch.conf
+     bzr bind bzr+ssh://USER@elpa.gnu.org/home/elpa/package-repo
+
+   Now you should be able to do `bzr up' and `bzr commit'.
+
+3. Changes in bzr do not immediately propagate to the user-facing tree
+   (i.e., what users see when they do `M-x list-packages').  That tree
+   is created by a (daily) cron job that does "bzr export".  If for
+   some reason you need to refresh the user-facing tree immediately,
+   run /home/elpa/bin/package-update.sh as the "elpa" user.
+
+   The Org mode dailies are not part of the repository.  After the
+   package-update.sh script creates the user-facing tree, it copies
+   the daily tarfile hosted on orgmode.org directly into that tree.
+
+4. FIXME: How to actually upload a package file.
--- a/configure	Mon Nov 08 14:19:24 2010 +0900
+++ b/configure	Mon Nov 08 14:19:54 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
@@ -13955,14 +13982,6 @@
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <time.h>
-extern char **environ;
-unset_TZ ()
-{
-  char **from, **to;
-  for (to = from = environ; (*to = *from); from++)
-    if (! (to[0][0] == 'T' && to[0][1] == 'Z' && to[0][2] == '='))
-      to++;
-}
 char TZ_GMT0[] = "TZ=GMT0";
 char TZ_PST8[] = "TZ=PST8";
 main()
@@ -13972,13 +13991,13 @@
   if (putenv (TZ_GMT0) != 0)
     exit (1);
   hour_GMT0 = localtime (&now)->tm_hour;
-  unset_TZ ();
+  unsetenv("TZ");
   hour_unset = localtime (&now)->tm_hour;
   if (putenv (TZ_PST8) != 0)
     exit (1);
   if (localtime (&now)->tm_hour == hour_GMT0)
     exit (1);
-  unset_TZ ();
+  unsetenv("TZ");
   if (localtime (&now)->tm_hour != hour_unset)
     exit (1);
   exit (0);
@@ -14011,7 +14030,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 +14041,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 +14085,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 +14093,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 +14103,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 +14120,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 +14150,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 +14163,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 +14176,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 +14187,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 +14240,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 +14376,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 +14408,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 +14420,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 +14456,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 +14510,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 +14557,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 +14714,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 +14927,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 +14986,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 +15099,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 +15129,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 +15146,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 +15247,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 +15293,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 +15501,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 +15555,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 +15621,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 +15640,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 +15671,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 +15684,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 +15693,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 +15761,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 +15784,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 +15795,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 +15835,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 +15860,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 +15879,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 +15927,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 +15965,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 +15999,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 +16011,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 +16100,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 +16113,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 +16132,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 +16141,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 +16167,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 +16300,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 +16329,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 +16380,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 +16401,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	Mon Nov 08 14:19:24 2010 +0900
+++ b/configure.in	Mon Nov 08 14:19:54 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"
@@ -2952,14 +2952,6 @@
 AC_CACHE_VAL(emacs_cv_localtime_cache,
 [if test x$ac_cv_func_tzset = xyes; then
 AC_TRY_RUN([#include <time.h>
-extern char **environ;
-unset_TZ ()
-{
-  char **from, **to;
-  for (to = from = environ; (*to = *from); from++)
-    if (! (to[0][0] == 'T' && to[0][1] == 'Z' && to[0][2] == '='))
-      to++;
-}
 char TZ_GMT0[] = "TZ=GMT0";
 char TZ_PST8[] = "TZ=PST8";
 main()
@@ -2969,13 +2961,13 @@
   if (putenv (TZ_GMT0) != 0)
     exit (1);
   hour_GMT0 = localtime (&now)->tm_hour;
-  unset_TZ ();
+  unsetenv("TZ");
   hour_unset = localtime (&now)->tm_hour;
   if (putenv (TZ_PST8) != 0)
     exit (1);
   if (localtime (&now)->tm_hour == hour_GMT0)
     exit (1);
-  unset_TZ ();
+  unsetenv("TZ");
   if (localtime (&now)->tm_hour != hour_unset)
     exit (1);
   exit (0);
@@ -3260,9 +3252,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 +3460,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 +3704,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	Mon Nov 08 14:19:24 2010 +0900
+++ b/doc/lispref/ChangeLog	Mon Nov 08 14:19:54 2010 +0900
@@ -1,3 +1,30 @@
+2010-10-31  Glenn Morris  <rgm@gnu.org>
+
+	* maps.texi (Standard Keymaps): Update File menu description.
+
+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	Mon Nov 08 14:19:24 2010 +0900
+++ b/doc/lispref/Makefile.in	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/doc/lispref/display.texi	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/doc/lispref/frames.texi	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/doc/lispref/help.texi	Mon Nov 08 14:19:54 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/maps.texi	Mon Nov 08 14:19:24 2010 +0900
+++ b/doc/lispref/maps.texi	Mon Nov 08 14:19:54 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, 1999, 2001, 2002, 2003, 2004,
-@c   2005, 2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
+@c   2005, 2006, 2007, 2008, 2009, 2010
+@c   Free Software Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @setfilename ../../info/maps
 @node Standard Keymaps, Standard Hooks, Standard Buffer-Local Variables, Top
@@ -183,9 +184,9 @@
 @vindex menu-bar-edit-menu
 The keymap which displays the Edit menu in the menu bar.
 
-@item menu-bar-files-menu
-@vindex menu-bar-files-menu
-The keymap which displays the Files menu in the menu bar.
+@item menu-bar-file-menu
+@vindex menu-bar-file-menu
+The keymap which displays the File menu in the menu bar.
 
 @item menu-bar-help-menu
 @vindex menu-bar-help-menu
@@ -239,6 +240,3 @@
 A full keymap used by View mode.
 @end table
 
-@ignore
-   arch-tag: b741253c-7e23-4a02-b3fa-cffd9e4d72b9
-@end ignore
--- a/doc/lispref/os.texi	Mon Nov 08 14:19:24 2010 +0900
+++ b/doc/lispref/os.texi	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/doc/misc/ChangeLog	Mon Nov 08 14:19:54 2010 +0900
@@ -1,3 +1,130 @@
+2010-11-04  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* gnus.texi (Customizing the IMAP Connection): Remove nnir mention,
+	since that works by default.
+
+2010-11-03  Kan-Ru Chen  <kanru@kanru.info>  (tiny change)
+
+	* gnus.texi (Customizing the IMAP Connection): Document
+	`nnimap-expunge' and remove `nnimap-expunge-inbox' from example.
+
+2010-11-04  Michael Albinus  <michael.albinus@gmx.de>
+
+	* tramp.texi (Remote shell setup): New item "Interactive shell
+	prompt".  Reported by Christian Millour <cm@abtela.com>.
+	(Remote shell setup, Remote processes): Use @code{} for
+	environment variables.
+
+2010-11-03  Glenn Morris  <rgm@gnu.org>
+
+	* ediff.texi (Quick Help Commands, Miscellaneous):
+	* gnus.texi (Agent Variables, Configuring nnmairix): Spelling fix.
+
+2010-10-31  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* gnus.texi (Paging the Article): Document C-u g/C-u C-u g.
+
+2010-10-31  Glenn Morris  <rgm@gnu.org>
+
+	* mh-e.texi (Preface, From Bill Wohler): Change 23 to past tense.
+
+2010-10-31  Glenn Morris  <rgm@gnu.org>
+
+	* cc-mode.texi: Remove reference to defunct viewcvs URL.
+
+2010-10-29  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* gnus.texi (Client-Side IMAP Splitting): Mention
+	nnimap-unsplittable-articles.
+
+2010-10-29  Julien Danjou  <julien@danjou.info>
+
+	* gnus.texi (Finding the News): Remove references to obsoletes
+	variables `gnus-nntp-server' and `gnus-secondary-servers'.
+
+2010-10-29  Eli Zaretskii  <eliz@gnu.org>
+
+	* makefile.w32-in (MAKEINFO): Add -I$(emacsdir).
+	(ENVADD): Remove extra -I$(emacsdir), included in $(MAKEINFO).
+	($(infodir)/efaq): Remove -I$(emacsdir), included in $(MAKEINFO).
+	($(infodir)/calc, calc.dvi): Depend on $(emacsdir)/emacsver.texi.
+
+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	Mon Nov 08 14:19:24 2010 +0900
+++ b/doc/misc/Makefile.in	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/doc/misc/auth.texi	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/doc/misc/calc.texi	Mon Nov 08 14:19:54 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/cc-mode.texi	Mon Nov 08 14:19:24 2010 +0900
+++ b/doc/misc/cc-mode.texi	Mon Nov 08 14:19:54 2010 +0900
@@ -160,7 +160,8 @@
 This manual is for CC Mode in Emacs.
 
 Copyright @copyright{} 1995, 1996, 1997, 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.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
@@ -201,9 +202,8 @@
 @vskip 0pt plus 1filll
 @insertcopying
 
-This manual was generated from cc-mode.texi, which can be downloaded
-from
-@url{http://cvs.savannah.gnu.org/viewcvs/emacs/emacs/doc/misc/cc-mode.texi}.
+This manual was generated from cc-mode.texi, which is distributed with Emacs,
+or can be downloaded from @url{http://savannah.gnu.org/projects/emacs/}.
 @end titlepage
 
 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -7015,6 +7015,3 @@
 
 @bye
 
-@ignore
-   arch-tag: c4cab162-5e57-4366-bdce-4a9db2fc97f0
-@end ignore
--- a/doc/misc/ediff.texi	Mon Nov 08 14:19:24 2010 +0900
+++ b/doc/misc/ediff.texi	Mon Nov 08 14:19:54 2010 +0900
@@ -759,7 +759,7 @@
 You can then restart any of these sessions by either clicking on a session
 record or by putting the cursor over it and then typing the return key.
 
-(Some poor souls leave so many active Ediff sessions around that they loose
+(Some poor souls leave so many active Ediff sessions around that they lose
 track of them completely...  The `R' command is designed to save these
 people from the recently discovered Ediff Proficiency Syndrome.)
 
@@ -2315,7 +2315,7 @@
 
 However, Ediff temporarily resets this variable to @code{t} if it is
 invoked via one of the "buffer" jobs, such as @code{ediff-buffers}.
-This is because it is all too easy to loose day's work otherwise.
+This is because it is all too easy to lose a day's work otherwise.
 Besides, in a "buffer" job, the variant buffers have already been loaded
 prior to starting Ediff, so Ediff just preserves status quo here.
 
@@ -2542,6 +2542,3 @@
 
 @bye
 
-@ignore
-   arch-tag: 165ecb88-d03c-44b1-a921-b93f50b05b46
-@end ignore
--- a/doc/misc/emacs-mime.texi	Mon Nov 08 14:19:24 2010 +0900
+++ b/doc/misc/emacs-mime.texi	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/doc/misc/epa.texi	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/doc/misc/gnus-coding.texi	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/doc/misc/gnus-news.texi	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/doc/misc/gnus.texi	Mon Nov 08 14:19:54 2010 +0900
@@ -1020,22 +1020,6 @@
 If that fails as well, Gnus will try to use the machine running Emacs
 as an @acronym{NNTP} server.  That's a long shot, though.
 
-@vindex gnus-nntp-server
-If @code{gnus-nntp-server} is set, this variable will override
-@code{gnus-select-method}.  You should therefore set
-@code{gnus-nntp-server} to @code{nil}, which is what it is by default.
-
-@vindex gnus-secondary-servers
-@vindex gnus-nntp-server
-You can also make Gnus prompt you interactively for the name of an
-@acronym{NNTP} server.  If you give a non-numerical prefix to @code{gnus}
-(i.e., @kbd{C-u M-x gnus}), Gnus will let you choose between the servers
-in the @code{gnus-secondary-servers} list (if any).  You can also just
-type in the name of any server you feel like visiting.  (Note that this
-will set @code{gnus-nntp-server}, which means that if you then @kbd{M-x
-gnus} later in the same Emacs session, Gnus will contact the same
-server.)
-
 @findex gnus-group-browse-foreign-server
 @kindex B (Group)
 However, if you use one @acronym{NNTP} server regularly and are just
@@ -2211,6 +2195,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 +2399,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 +3078,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.
@@ -4563,7 +4556,7 @@
 server exclusively for @code{nnmairix} in your secondary select methods
 (@pxref{Finding the News}).  If you use a secondary @code{nnml} server
 just for mairix, make sure that you explicitly set the server variable
-@code{nnml-get-new-mail} to @code{nil}, or you might loose mail
+@code{nnml-get-new-mail} to @code{nil}, or you might lose mail
 (@pxref{nnmairix caveats}).  If you want to use mairix remotely on an
 @acronym{IMAP} server, you have to choose the corresponding
 @code{nnimap} server here.
@@ -5195,24 +5188,6 @@
 If fetching from the first site is unsuccessful, Gnus will attempt to go
 through @code{gnus-group-faq-directory} and try to open them one by one.
 
-@item H C
-@kindex H C (Group)
-@findex gnus-group-fetch-control
-@vindex gnus-group-fetch-control-use-browse-url
-@cindex control message
-Fetch the control messages for the group from the archive at
-@code{ftp.isc.org} (@code{gnus-group-fetch-control}).  Query for a
-group if given a prefix argument.
-
-If @code{gnus-group-fetch-control-use-browse-url} is non-@code{nil},
-Gnus will open the control messages in a browser using
-@code{browse-url}.  Otherwise they are fetched using @code{ange-ftp}
-and displayed in an ephemeral group.
-
-Note that the control messages are compressed.  To use this command
-you need to turn on @code{auto-compression-mode} (@pxref{Compressed
-Files, ,Compressed Files, emacs, The Emacs Manual}).
-
 @item H d
 @itemx C-c C-d
 @c @icon{gnus-group-describe-group}
@@ -6178,8 +6153,9 @@
 @vindex gnus-summary-show-article-charset-alist
 (Re)fetch the current article (@code{gnus-summary-show-article}).  If
 given a prefix, fetch the current article, but don't run any of the
-article treatment functions.  This will give you a ``raw'' article, just
-the way it came from the server.
+article treatment functions.  If given a prefix twice (i.e., @kbd{C-u
+C-u g'}), show a completely ``raw'' article, just the way it came from
+the server.
 
 @cindex charset, view article with different charset
 If given a numerical prefix, you can do semi-manual charset stuff.
@@ -9803,19 +9779,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 +12435,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
@@ -13451,14 +13429,20 @@
 name will be removed.  If the attribute name is @code{eval}, the form
 is evaluated, and the result is thrown away.
 
-The attribute value can be a string (used verbatim), a function with
-zero arguments (the return value will be used), a variable (its value
-will be used) or a list (it will be @code{eval}ed and the return value
-will be used).  The functions and sexps are called/@code{eval}ed in the
-message buffer that is being set up.  The headers of the current article
-are available through the @code{message-reply-headers} variable, which
-is a vector of the following headers: number subject from date id
-references chars lines xref extra.
+The attribute value can be a string, a function with zero arguments
+(the return value will be used), a variable (its value will be used)
+or a list (it will be @code{eval}ed and the return value will be
+used).  The functions and sexps are called/@code{eval}ed in the
+message buffer that is being set up.  The headers of the current
+article are available through the @code{message-reply-headers}
+variable, which is a vector of the following headers: number subject
+from date id references chars lines xref extra.
+
+In the case of a string value, if the @code{match} is a regular
+expression, a @samp{gnus-match-substitute-replacement} is proceed on
+the value to replace the positional parameters @samp{\@var{n}} by the
+corresponding parenthetical matches (see @xref{Replacing the Text that
+Matched, , Text Replacement, elisp, The Emacs Lisp Reference Manual}.)
 
 @vindex message-reply-headers
 
@@ -14861,9 +14845,7 @@
         (nnimap-inbox "INBOX")
         (nnimap-split-methods default)
         (nnimap-expunge t)
-        (nnimap-stream ssl)
-        (nnir-search-engine imap)
-        (nnimap-expunge-inbox t))
+        (nnimap-stream ssl))
 @end example
 
 @table @code
@@ -14872,7 +14854,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:
@@ -14899,6 +14881,11 @@
 Some @acronym{IMAP} servers allow anonymous logins.  In that case,
 this should be set to @code{anonymous}.
 
+@item nnimap-expunge
+If non-@code{nil}, expunge articles after deleting them.  This is always done
+if the server supports UID EXPUNGE, but it's not done by default on
+servers that doesn't support that command.
+
 @item nnimap-streaming
 Virtually all @code{IMAP} server support fast streaming of data.  If
 you have problems connecting to the server, try setting this to @code{nil}.
@@ -14934,6 +14921,11 @@
 @item nnimap-split-fancy
 Uses the same syntax as @code{nnmail-split-fancy}.
 
+@item nnimap-unsplittable-articles
+List of flag symbols to ignore when doing splitting.  That is,
+articles that have these flags won't be considered when splitting.
+The default is @samp{(%Deleted %Seen)}.
+
 @end table
 
 
@@ -17711,15 +17703,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 +17952,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.
@@ -19856,7 +19843,7 @@
 performance.  A small value minimizes the time lost should the
 connection be lost while fetching (You may need to run
 @code{gnus-agent-regenerate-group} to update the group's state.
-However, all articles parsed prior to loosing the connection will be
+However, all articles parsed prior to losing the connection will be
 available while unplugged).  The default is 10M so it is unusual to
 see any cycling.
 
@@ -30096,11 +30083,11 @@
 (setq gnus-read-active-file 'some)
 @end lisp
 
-On the other hand, if the manual says ``set @code{gnus-nntp-server} to
-@samp{nntp.ifi.uio.no}'', that means:
-
-@lisp
-(setq gnus-nntp-server "nntp.ifi.uio.no")
+On the other hand, if the manual says ``set @code{gnus-nntp-server-file} to
+@samp{/etc/nntpserver}'', that means:
+
+@lisp
+(setq gnus-nntp-server-file "/etc/nntpserver")
 @end lisp
 
 So be careful not to mix up strings (the latter) with symbols (the
--- a/doc/misc/makefile.w32-in	Mon Nov 08 14:19:24 2010 +0900
+++ b/doc/misc/makefile.w32-in	Mon Nov 08 14:19:54 2010 +0900
@@ -32,7 +32,7 @@
 emacsdir = $(srcdir)/../emacs
 
 # The makeinfo program is part of the Texinfo distribution.
-MAKEINFO = makeinfo --force
+MAKEINFO = makeinfo --force -I$(emacsdir)
 MULTI_INSTALL_INFO = $(srcdir)\..\..\nt\multi-install-info.bat
 INFO_TARGETS = $(infodir)/ccmode \
 		$(infodir)/cl $(infodir)/dbus $(infodir)/dired-x \
@@ -70,7 +70,7 @@
 
 TEXI2DVI = texi2dvi
 ENVADD = $(srcdir)\..\..\nt\envadd.bat "TEXINPUTS=$(srcdir);$(TEXINPUTS)" \
-	 "MAKEINFO=$(MAKEINFO) -I$(srcdir) -I$(emacsdir)" /C
+	 "MAKEINFO=$(MAKEINFO) -I$(srcdir)" /C
 
 
 info: $(INFO_TARGETS)
@@ -218,7 +218,7 @@
 	$(ENVADD) $(TEXI2DVI) $(srcdir)/widget.texi
 
 $(infodir)/efaq: faq.texi $(emacsdir)/emacsver.texi
-	$(MAKEINFO) -I$(emacsdir) faq.texi
+	$(MAKEINFO) faq.texi
 faq.dvi: faq.texi $(emacsdir)/emacsver.texi
 	$(ENVADD) $(TEXI2DVI) $(srcdir)/faq.texi
 
@@ -227,10 +227,10 @@
 autotype.dvi: autotype.texi
 	$(ENVADD) $(TEXI2DVI) $(srcdir)/autotype.texi
 
-$(infodir)/calc: calc.texi
+$(infodir)/calc: calc.texi $(emacsdir)/emacsver.texi
 	$(MAKEINFO) calc.texi
 
-calc.dvi: calc.texi
+calc.dvi: calc.texi $(emacsdir)/emacsver.texi
 	$(ENVADD) $(TEXI2DVI) $(srcdir)/calc.texi
 
 # This is produced with --no-split to avoid making files whose
--- a/doc/misc/message.texi	Mon Nov 08 14:19:24 2010 +0900
+++ b/doc/misc/message.texi	Mon Nov 08 14:19:54 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/doc/misc/mh-e.texi	Mon Nov 08 14:19:24 2010 +0900
+++ b/doc/misc/mh-e.texi	Mon Nov 08 14:19:54 2010 +0900
@@ -213,7 +213,7 @@
 them.
 
 The MH-E package is distributed with GNU Emacs@footnote{Version
-@value{VERSION} of MH-E will appear in GNU Emacs 23.1. It is supported
+@value{VERSION} of MH-E appeared in GNU Emacs 23.1. It is supported
 in GNU Emacs 21 and 22, as well as XEmacs 21 (except for versions
 21.5.9-21.5.16). It is compatible with MH versions 6.8.4 and higher,
 all versions of nmh, and GNU mailutils 1.0 and higher.}, so you
@@ -8951,8 +8951,8 @@
 reorganized to push back two decades of entropy. Version 8 appeared in
 Emacs 22.1 in 2006.
 
-Development was then quiet for a couple of years. Emacs 23.1, which is
-due out in 2009, will contain version 8.1. This version includes a few
+Development was then quiet for a couple of years. Emacs 23.1, released
+in June 2009, contains version 8.2.  This version includes a few
 new features and several bug fixes.
 
 Bill Wohler, August 2008
@@ -9061,6 +9061,4 @@
 @c sentence-end-double-space: nil
 @c End:
 
-@ignore
-   arch-tag: b778477d-1a10-4a99-84de-f877a2ea6bef
-@end ignore
+
Binary file doc/misc/tramp.texi has changed
--- a/etc/ChangeLog	Mon Nov 08 14:19:24 2010 +0900
+++ b/etc/ChangeLog	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/etc/DISTRIB	Mon Nov 08 14:19:54 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/MH-E-NEWS	Mon Nov 08 14:19:24 2010 +0900
+++ b/etc/MH-E-NEWS	Mon Nov 08 14:19:54 2010 +0900
@@ -1,13 +1,13 @@
 * COPYRIGHT
 
-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.
 
 
 * Changes in MH-E 8.2
 
-Version 8.2 of MH-E will appear in GNU Emacs 23.1. This is a small
+Version 8.2 of MH-E appeared in GNU Emacs 23.1.  This is a small
 release that includes internal changes from the Emacs team. A new
 hook, `mh-pack-folder-hook', has been added.
 
@@ -231,7 +231,7 @@
 If you want to see the release notes for the alpha and beta releases
 leading up this release, please see:
 
-  http://cvs.savannah.gnu.org/viewcvs/emacs/etc/MH-E-NEWS?rev=1.25&root=emacs&view=markup
+  http://cvs.savannah.gnu.org/viewvc/emacs/emacs/etc/MH-E-NEWS?revision=1.25&view=markup
 
 
 
--- a/etc/NEWS	Mon Nov 08 14:19:24 2010 +0900
+++ b/etc/NEWS	Mon Nov 08 14:19:54 2010 +0900
@@ -38,10 +38,6 @@
 lib-src/Makefile by hand in order to use the associated features.
 
 ---
-** There is a new configure option --with-crt-dir.
-This is only useful if your crt*.o files are in a non-standard location.
-
----
 ** Emacs can be compiled against Gtk+ 3.0 if you pass --with-x-toolkit=gtk3
 to configure.  Note that other libraries used by Emacs, RSVG and GConf,
 also depend on Gtk+.  You can disable them with --without-rsvg and
@@ -138,7 +134,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.
@@ -183,7 +183,7 @@
 
 ** An Emacs Lisp package manager is now included.
 This is a convenient way to download and install additional packages,
-from elpa.gnu.org.
+from a package repository at elpa.gnu.org.
 
 *** `M-x list-packages' shows a list of packages, which can be
 selected for installation.
@@ -199,9 +199,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
 
@@ -215,8 +223,8 @@
 kill instead.
 
 *** New command `delete-forward-char', bound to C-d and [delete].
-This is meant for interactive use, and obeys `delete-active-region';
-delete-char, meant for Lisp, does not obey `delete-active-region'.
+This is meant for interactive use, and obeys `delete-active-region'.
+The command `delete-char' does not obey `delete-active-region'.
 
 *** `delete-backward-char' is now a Lisp function.
 Apart from obeying `delete-active-region', its behavior is unchanged.
@@ -228,24 +236,53 @@
 ** Selection changes.
 
 The default handling of clipboard and primary selections has been
-changed to conform with other X applications.
+changed to conform with other X applications.  The exact changes are
+described below; in short, mouse commands to select and paste text now
+use the primary selection, while all other commands for killing and
+yanking text now use the clipboard.
+
+*** Merely selecting text (e.g. with drag-mouse-1) does not add it to
+the kill-ring.  On systems with a primary selection separate from the
+clipboard (such as X), the selected text is put in the primary
+selection.
+
+*** mouse-2 is now bound to `mouse-yank-primary', which pastes from
+the primary selection regardless of the contents of the kill-ring.
 
-*** `select-active-regions' now defaults to t, so active regions set
-the primary selection.
+*** Commands that kill text or copy it to the kill-ring (M-w, C-w,
+C-k, etc.) also put the killed text into the clipboard.  This change
+also means that the "Copy", "Cut", and "Paste" items in the "Edit"
+menu are now exactly equivalent to, respectively M-w, C-w, and C-y.
 
-It also accepts a new value, `lazy', which means to only set the
+*** Yank commands, such as C-y and M-y, retrieve text from the
+clipboard if it is available.
+
+*** The above changes are reflected in the following new defaults:
+
+**** `select-active-regions' now defaults to t.
+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'.
+**** `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 on all platforms.
+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-clipboard' now defaults to t.
-Thus, killing and yanking now use the clipboard (in addition to the
-kill ring).
+**** `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.
 
-*** `x-select-enable-primary' now defaults to nil.
-
-*** `mouse-drag-copy-region' now defaults to nil.
+*** To return to the previous behavior, where mouse commands use the
+clipboard, change `mouse-drag-copy-region' and (on X only)
+`x-select-enable-primary' to t.  If you don't want Emacs to put the
+text into the clipboard, only to the primary selection, additionally
+set `x-select-enable-clipboard' to nil.
 
 *** Support for X cut buffers has been removed.
 
@@ -266,6 +303,11 @@
 seconds.  The default value, 'ident, means to autojoin immediately
 after connecting.
 
+*** New variable `erc-coding-system-precedence': If we use `undecided'
+as the server coding system, this variable will then be consulted.
+The default is to decode strings that can be decoded as utf-8 as
+utf-8, and do the normal `undecided' decoding for the rest.
+
 ** In ido-mode, C-v is no longer bound to ido-toggle-vc.
 The reason is that this interferes with cua-mode.
 
@@ -276,6 +318,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
 
 ---
@@ -295,7 +339,7 @@
 
 *** Customize buffers now contain a search field.
 The search is performed using `customize-apropos'.
-To turn off the search field, set custom-search-field to nil .
+To turn off the search field, set custom-search-field to nil.
 
 *** Custom options now start out hidden if at their default values.
 Use the arrow to the left of the option name to toggle visibility.
@@ -310,41 +354,6 @@
 *** dired-jump and dired-jump-other-window called with a prefix argument
 read a file name from the minibuffer instead of using buffer-file-name.
 
-** VC and related modes
-
-*** New VC commands: vc-log-incoming, vc-log-outgoing, vc-find-conflicted-file.
-
-**** vc-log-incoming for Git runs "git fetch" so that the necessary
-data is available locally.
-
-**** vc-log-incoming and vc-log-outgoing for Git require version 1.7 (or newer).
-
-*** New key bindings: C-x v I and C-x v O bound to vc-log-incoming and
-vc-log-outgoing, respectively.
-
-*** The 'g' key in VC diff, log, log-incoming and log-outgoing buffers
-reruns the corresponding VC command to compute an up to date version
-of the buffer.
-
-*** vc-dir for Bzr supports viewing shelve contents and shelving snapshots.
-
-*** Special markup can be added to log-edit buffers.
-The log-edit buffers are expected to have a format similar to email messages
-with headers of the form:
-  Author: <author of this change>
-  Summary: <one line summary of this change>
-  Fixes: <reference to the bug fixed by this change>
-Some backends handle some of those headers specially, but any unknown header
-is just left as is in the message, so it is not lost.
-
-**** vc-git handles Author: and Date:
-**** vc-hg handles  Author: and Date:
-**** vc-bzr handles Author:, Date: and Fixes:
-**** vc-mtn handles Author: and Date:
-
-*** Pressing g in a *vc-diff* buffer reruns vc-diff, so it will
-produce an up to date diff.
-
 ** Directory local variables can apply to file-less buffers.
 For example, adding "(diff-mode . ((mode . whitespace)))" to your
 .dir-locals.el file, will turn on `whitespace-mode' for *vc-diff* buffers.
@@ -532,6 +541,8 @@
 
 * Incompatible Lisp Changes in Emacs 24.1
 
+** Remove obsolete name `e' (use `float-e' instead).
+
 ** A backquote not followed by a space is now always treated as new-style.
 
 ** Test for special mode-class was moved from view-file to view-buffer.
@@ -575,9 +586,16 @@
 ** The following files, obsolete since at least Emacs 21.1, have been removed:
 sc.el, x-menu.el, rnews.el, rnewspost.el
 
+** FIXME finder-inf.el changes.
+
 
 * 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 +623,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	Mon Nov 08 14:19:24 2010 +0900
+++ b/etc/NEWS.1-17	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/etc/NEWS.23	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/etc/PROBLEMS	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/etc/images/README	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:54 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",
+"............",
+"............",
+"..@@@@@@@@+.",
+"..@@@@@@@@+.",
+"..@@@@@@@@+.",
+"..@@@@@@@@+.",
+"..@@@@@@@@+.",
+"..@@@@@@@@+.",
+"..@@@@@@@@+.",
+"..@++++++++.",
+".@+++++++++.",
+"............"};
--- a/etc/schema/schemas.xml	Mon Nov 08 14:19:24 2010 +0900
+++ b/etc/schema/schemas.xml	Mon Nov 08 14:19:54 2010 +0900
@@ -22,7 +22,7 @@
   <uri pattern="*.html" typeId="XHTML"/>
   <uri pattern="*.rng" typeId="RELAX NG"/>
   <uri pattern="*.rdf" typeId="RDF"/>
-  
+
   <namespace ns="http://www.w3.org/1999/XSL/Transform" typeId="XSLT"/>
   <namespace ns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" typeId="RDF"/>
   <namespace ns="http://www.w3.org/1999/xhtml" typeId="XHTML"/>
@@ -39,10 +39,14 @@
 
   <documentElement prefix="" localName="article" typeId="DocBook"/>
   <documentElement prefix="" localName="book" typeId="DocBook"/>
+  <documentElement prefix="" localName="chapter" typeId="DocBook"/>
+  <documentElement prefix="" localName="part" typeId="DocBook"/>
+  <documentElement prefix="" localName="refentry" typeId="DocBook"/>
+  <documentElement prefix="" localName="section" typeId="DocBook"/>
 
   <documentElement localName="RDF" typeId="RDF"/>
   <documentElement prefix="rdf" typeId="RDF"/>
-  
+
   <documentElement localName="locatingRules" uri="locate.rnc"/>
 
   <typeId id="XSLT" uri="xslt.rnc"/>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/etc/themes/tango-dark-theme.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/etc/tutorials/TUTORIAL	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/etc/tutorials/TUTORIAL.es	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lib-src/ChangeLog	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lib-src/Makefile.in	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lib-src/makefile.w32-in	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/ChangeLog	Mon Nov 08 14:19:54 2010 +0900
@@ -1,3 +1,1191 @@
+2010-11-07  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* emacs-lisp/smie.el: Simplify the smie-rules-function return values.
+	(smie-precs->prec2): Rename from smie-precs-precedence-table.
+	(smie-bnf->prec2): Rename from smie-bnf-precedence-table.
+	(smie-prec2->grammar): Rename from smie-prec2-levels.
+	(smie-grammar): Rename from smie-op-levels.
+	(smie-indent--hanging-p): Rename from smie-hanging-p.
+	(smie-rule-hanging-p): New alias.
+	(smie-indent--bolp): Rename from smie-bolp.
+	(smie-indent--hanging-p): New alias.
+	(smie--token): New dynamically bound variable.
+	(smie-indent--parent): New function.
+	(smie-rule-parent-p): Use it; rename from smie-parent-p.
+	(smie-rule-next-p): Rename from smie-next-p.
+	(smie-rule-prev-p): Rename from smie-prev-p.
+	(smie-rule-sibling-p, smie-rule-parent)
+	(smie-indent--separator-outdent, smie-rule-separator): New functions.
+	(smie-rule-separator-outdent): New var.
+	(smie-indent--rule): Merge with smie-indent--column.
+	(smie-indent-forward-token, smie-indent-backward-token):
+	Also recognize close parens.
+	(smie-indent-keyword): Don't use smie-indent--column any more.
+	(smie-indent-after-keyword): Ignore closers by default.
+	(smie-indent-line): Use with-demoted-errors.
+	* progmodes/octave-mod.el (octave-smie-grammar):
+	Rename from octave-smie-op-levels.
+	(octave-smie-rules): Adjust to new behavior.
+	* progmodes/prolog.el (prolog-smie-grammar):
+	Rename from prolog-smie-op-levels.
+
+2010-11-07  Glenn Morris  <rgm@gnu.org>
+
+	* eshell/esh-util.el (subst-char-in-string)
+	(directory-files-and-attributes): These compatibility definitions are
+	not needed on any version of Emacs since at least 21.4.
+
+	* progmodes/verilog-mode.el (verilog-get-beg-of-line)
+	(verilog-get-end-of-line): Remove.
+	(verilog-within-string, verilog-re-search-forward-substr)
+	(verilog-re-search-backward-substr, verilog-set-auto-endcomments)
+	(verilog-surelint-off, verilog-getopt-file, verilog-highlight-region):
+	Use point-at-bol, point-at-eol.
+	* progmodes/pascal.el (pascal-get-beg-of-line, pascal-get-end-of-line):
+	Remove.
+	(pascal-declaration-end, pascal-declaration-beg, pascal-within-string)
+	(electric-pascal-terminate-line, pascal-set-auto-comments)
+	(pascal-indent-paramlist, pascal-indent-declaration)
+	(pascal-get-lineup-indent, pascal-func-completion)
+	(pascal-get-completion-decl, pascal-var-completion, pascal-completion):
+	Use point-at-bol, point-at-eol.
+	* progmodes/flymake.el (flymake-line-beginning-position)
+	(flymake-line-end-position): Remove.
+	(flymake-highlight-line): Use point-at-bol, point-at-eol.
+	* eshell/esh-util.el (line-end-position, line-beginning-position):
+	Remove compat definitions.
+
+	* emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
+	Use end-of-line N.
+	(checkdoc-this-string-valid-engine, checkdoc-file-comments-engine):
+	Use line-end-position.
+
+	* emacs-lisp/chart.el (chart-zap-chars):
+	* play/decipher.el (decipher-set-map):
+	* progmodes/ada-mode.el (ada-get-current-indent)
+	(ada-search-ignore-string-comment, ada-tab-hard, ada-untab-hard):
+	* progmodes/ada-prj.el (ada-prj-load-from-file, ada-prj-display-help):
+	* progmodes/ada-xref.el (ada-initialize-runtime-library)
+	(ada-get-all-references):
+	* progmodes/cperl-mode.el (cperl-electric-paren)
+	(cperl-electric-rparen, cperl-electric-keyword, cperl-electric-else)
+	(cperl-linefeed, cperl-sniff-for-indent, cperl-to-comment-or-eol)
+	(cperl-find-pods-heres, cperl-indent-exp, cperl-fix-line-spacing)
+	(cperl-word-at-point-hard):
+	* progmodes/idlw-shell.el (idlwave-shell-move-or-history)
+	(idlwave-shell-filename-string, idlwave-shell-batch-command)
+	(idlwave-shell-display-line):
+	* progmodes/idlwave.el (idlwave-show-begin, idlwave-fill-paragraph)
+	(idlwave-calc-hanging-indent, idlwave-auto-fill, idlwave-template):
+	* progmodes/js.el (js--re-search-forward-inner)
+	(js--re-search-backward-inner):
+	* progmodes/vhdl-mode.el (vhdl-align-region-1, vhdl-align-region-2)
+	(vhdl-fix-clause, vhdl-compose-configuration-architecture):
+	* progmodes/ruby-mode.el (ruby-parse-partial, eval-when-compile):
+	* textmodes/flyspell.el (flyspell-process-localwords):
+	* textmodes/ispell.el (ispell-buffer-local-parsing)
+	(ispell-buffer-local-dict, ispell-buffer-local-words):
+	Use point-at-bol and point-at-eol.
+
+	* speedbar.el (speedbar-generic-item-info)
+	(speedbar-item-info-tag-helper, speedbar-change-expand-button-char)
+	(speedbar-add-indicator, speedbar-check-vc-this-line)
+	(speedbar-check-obj-this-line, speedbar-extract-one-symbol)
+	(speedbar-buffers-line-directory, speedbar-buffer-revert-buffer):
+	Replace more uses of end-of-line etc with line-end-position.
+
+2010-11-06  Glenn Morris  <rgm@gnu.org>
+
+	* textmodes/texnfo-upd.el (texinfo-start-menu-description)
+	(texinfo-update-menu-region-beginning, texinfo-menu-first-node)
+	(texinfo-delete-existing-pointers, texinfo-find-pointer)
+	(texinfo-clean-up-node-line, texinfo-insert-node-lines)
+	(texinfo-multiple-files-update):
+	* textmodes/table.el (table--probe-cell-left-up)
+	(table--probe-cell-right-bottom):
+	* textmodes/picture.el (picture-tab-search):
+	* textmodes/page-ext.el (pages-copy-header-and-position)
+	(pages-directory-for-addresses):
+	* progmodes/vera-mode.el (vera-get-offset):
+	* progmodes/simula.el (simula-calculate-indent):
+	* progmodes/python.el (python-pdbtrack-overlay-arrow):
+	* progmodes/prolog.el (end-of-prolog-clause):
+	* progmodes/perl-mode.el (perl-calculate-indent, perl-indent-exp):
+	* progmodes/icon.el (indent-icon-exp):
+	* progmodes/etags.el (tag-re-match-p):
+	* progmodes/ebrowse.el (ebrowse-show-file-name-at-point):
+	* progmodes/ebnf2ps.el (ebnf-begin-file):
+	* progmodes/dcl-mode.el (dcl-back-to-indentation-1)
+	(dcl-save-local-variable):
+	* play/life.el (life-setup):
+	* play/gametree.el (gametree-looking-at-ply):
+	* nxml/nxml-maint.el (nxml-insert-target-repertoire-glyph-set):
+	* mail/sendmail.el (mail-mode-auto-fill):
+	* emacs-lisp/lisp-mode.el (calculate-lisp-indent):
+	* emacs-lisp/edebug.el (edebug-overlay-arrow):
+	* emacs-lisp/checkdoc.el (checkdoc-this-string-valid):
+	* woman.el (woman-parse-numeric-value, woman2-TH, woman2-SH)
+	(woman-tab-to-tab-stop, WoMan-warn-ignored):
+	* type-break.el (type-break-file-keystroke-count):
+	* term.el (term-replace-by-expanded-history-before-point)
+	(term-skip-prompt, term-extract-string):
+	* speedbar.el (speedbar-edit-line, speedbar-expand-line)
+	(speedbar-contract-line, speedbar-toggle-line-expansion)
+	(speedbar-parse-c-or-c++tag, speedbar-parse-tex-string)
+	(speedbar-buffer-revert-buffer, speedbar-highlight-one-tag-line):
+	* sort.el (sort-skip-fields):
+	* skeleton.el (skeleton-internal-list):
+	* simple.el (line-move-finish, line-move-to-column):
+	* shell.el (shell-forward-command):
+	* misc.el (copy-from-above-command):
+	* makesum.el (double-column):
+	* ebuff-menu.el (electric-buffer-update-highlight):
+	* dired.el (dired-move-to-end-of-filename):
+	* dframe.el (dframe-popup-kludge):
+	* bookmark.el (bookmark-kill-line, bookmark-bmenu-show-filenames):
+	* arc-mode.el (archive-get-lineno):
+	Use line-end-position and line-beginning-position.
+
+	* progmodes/idlwave.el (idlwave-routine-entry-compare-twins):
+	(idlwave-study-twins): Prefix dynamic local `class'.
+	(idlwave-routine-twin-compare): Update for above name change.
+
+	* emacs-lisp/eieio-comp.el (byte-compile-file-form-defmethod):
+	Use boundp tests to silence compiler.  Update for changed name of
+	bytecomp-filename variable.
+
+	* emulation/viper-cmd.el (viper-read-string-with-history):
+	Prefix dynamic local `initial'.
+	(viper-minibuffer-standard-hook): Update for above name change.
+
+	* emacs-lisp/elint.el (elint-init-env): Prefix dynamic local `env'.
+	(elint-init-form): Update for above name change.
+
+	* mail/mail-extr.el (mail-extract-address-components): Give dynamic
+	local variables `cbeg' and `cend' a prefix.
+	(mail-extr-voodoo): Update for above name change.
+
+	* textmodes/reftex-toc.el (reftex-toc-do-promote)
+	(reftex-toc-promote-prepare): Pass `delta' as an explicit argument.
+	(reftex-toc-promote-action): Doc fix.
+
+	* textmodes/reftex-sel.el (reftex-select-item): Give local variables
+	`prompt', `data' a prefix.
+	(reftex-select-post-command-hook, reftex-select-callback)
+	(reftex-select-mouse-accept, reftex-select-read-cite):
+	Update for above name changes.
+
+	* textmodes/reftex-ref.el (reftex-reference): Rename local variable
+	`refstyle' to reftex-refstyle.
+	(reftex-offer-label-menu): Update for above name change.
+	* textmodes/reftex-sel.el (reftex-select-toggle-varioref): Update for
+	`refstyle' name change.
+
+	* vc/emerge.el (emerge-eval-in-buffer): Remove, and replace all uses
+	with with-current-buffer.
+	(diff, template): Give dynamic local variables a prefix.
+	(emerge-line-numbers): Rename local `diff' to emerge-line-diff.
+	(emerge-line-number-in-buf): Update for above name change.
+	(emerge-combine-versions-internal): Rename local `template' to
+	emerge-combine-template.
+	(emerge-combine-versions-edit): Update for above name change.
+
+2010-11-06  Ralf Angeli  <angeli@caeruleus.net>
+
+	* textmodes/reftex-cite.el
+	(reftex-extract-bib-entries-from-thebibliography): Match bibitem
+	entries with whitespace after \bibitem.
+	(reftex-create-bibtex-file): Match entries containing numbers and
+	symbol constituents.  Make sure that entries with whitespace at
+	various places are found.
+
+2010-11-05  Christian Millour  <cm@abtela.com>  (tiny change)
+
+	* shell.el (shell-process-popd): Made aware of comint-file-name-prefix.
+
+2010-11-05  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* mouse.el (mouse-yank-primary): Update comment (Bug#6802).
+
+2010-11-05  Glenn Morris  <rgm@gnu.org>
+
+	* woman.el (woman0-roff-buffer, woman1-roff-buffer)
+	(woman2-roff-buffer): Give local variable `request' a prefix.
+	(woman0-macro): Rename argument `request' in the same way.
+	(woman-request): New name for `request' dynamic variable.
+	(woman-unquote, woman-forward-arg): Update for above name change.
+	(woman1-roff-buffer): Give local variable `unquote' a prefix.
+	(woman1-unquote): New name for `unquote' dynamic variable.
+	(woman1-B-or-I, woman1-alt-fonts): Update for above name change.
+	(woman-translations): Rename from `translations'.  No longer global.
+	(woman2-tr, woman-translate): Update for above name change.
+	(woman-translate): Check for bound variable.
+	(woman2-roff-buffer): Give local variable `translations' a prefix.
+
+	* play/doctor.el: Give all local variables a prefix.  Update callers.
+	(doc$, doctor-put-meaning): Use backquote.
+
+	* emacs-lisp/cl-macs.el (loop): Give local variable args a prefix.
+	(cl-parse-loop-clause, cl-loop-handle-accum): Update for above change.
+
+	* emacs-lisp/byte-opt.el (byte-decompile-bytecode-1): Give local
+	variables bytes, ptr, op a prefix.
+	(disassemble-offset): Update for above change.
+
+2010-11-03  Chong Yidong  <cyd@stupidchicken.com>
+
+	* emacs-lisp/package.el (package-unpack): Remove no-op.
+	(package--builtins, package--dir): Doc fix.
+	(package-activate-1, package-activate, package-install)
+	(package-compute-transaction): Fix error message.
+	(package-delete): Use delete-directory.  Omit system packages.
+	(package-initialize): Set package-alist to nil first.
+	(package-menu-mark-delete, package-menu-mark-install): Don't add
+	symbols that are inconsistent with the package state.
+	(package-menu-execute): Perform deletions and installations as
+	single batch operations.
+
+2010-11-03  Glenn Morris  <rgm@gnu.org>
+
+	* progmodes/idlwave.el (idlwave-pset): Only used on XEmacs.
+	(props): Remove unnecessary declaration.
+
+	* textmodes/ispell.el (ispell-init-process): On Emacs, always use
+	set-process-query-on-exit-flag.
+
+	* textmodes/reftex-toc.el (name1, dummy, dummy2): Remove unused decs.
+	(reftex-toc-do-promote): Remove unused local `mpos'.
+	(reftex-toc-restore-region): Make `mpos' local to this function.
+
+	* net/dbus.el (dbus-name-owner-changed-handler): Doc fix.
+
+	* play/landmark.el (lm-losing-threshold): Correct spelling.
+	(lm-human-plays): Use new name.
+
+	* play/gomoku.el (gomoku-loosing-threshold): Correct spelling.
+	(gomoku-human-plays): Use new name.
+
+	* play/gomoku.el (nil-score, Xscore, XXscore, XXXscore, XXXXscore)
+	(Oscore, OOscore, OOOscore, OOOOscore): Rename with gomoku- prefix.
+	(gomoku-score-trans-table, gomoku-winning-threshold)
+	(gomoku-loosing-threshold, gomoku-init-score-table): Use new names.
+
+2010-11-03  Chong Yidong  <cyd@stupidchicken.com>
+
+	* emacs-lisp/package.el: Don't put built-in packages in
+	package-alist, to avoid loading inefficiencies.
+	(package-built-in-p): Make VERSION optional, and treat it as a
+	minimum acceptable version.
+	(package-activate): Search separately for built-in packages.  Emit
+	a warning if a dependency fails.
+	(define-package): Handle most common case, where there is no
+	obsolete package, first.
+	(package-compute-transaction): Print required version in error.
+	(package--initialized): New variable.
+	(list-packages): Use it.
+	(package-initialize): Optional arg NO-ACTIVATE.  Don't put
+	built-in packages in packages-alist; keep it separate.  Set
+	package--initialized.
+	(describe-package): Avoid activating packages as a side-effect.
+	Search separately for built-in packages.
+	(describe-package-1): Handle the case where an elpa package is
+	simultaneously built-in and available/installed.
+	(package-installed-p, package--generate-package-list): Search
+	separately for built-in packages.
+	(package-load-descriptor): Doc fix.
+
+2010-11-03  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* progmodes/perl-mode.el (perl-syntax-propertize-function):
+	Handle __DATA__ and __END__.
+
+2010-11-02  Noah Friedman  <friedman@splode.com>
+
+	* emacs-lisp/bytecomp.el (byte-recompile-file): If bytecomp-arg is
+	nil, do not ask to recompile files that are not already compiled,
+	and do not recompile them.
+
+2010-11-02  Chong Yidong  <cyd@stupidchicken.com>
+
+	* emacs-lisp/package.el (package-initialize): Ensure that
+	obsoleted built-in packages are not in package-activated-list
+	during activation.
+	(describe-package-1): Make the "installed" status override
+	"built-in".
+
+2010-11-01  Vinicius Jose Latorre  <viniciusjl@ig.com.br>
+
+	* subr.el (version-separator, version-regexp-alist): Remove '*'
+	from docstring.
+	(version-list-<=, version<=, version=): Doc fix.
+
+2010-11-01  Kenichi Handa  <handa@m17n.org>
+
+	* faces.el (glyphless-char): Inherit underline for tty.
+
+2010-11-01  Kenichi Handa  <handa@m17n.org>
+
+	Implement various display methods for glyphless characters.
+
+	* international/characters.el (char-acronym-table): New variable.
+	(glyphless-char-control): New variable.
+	(update-glyphless-char-display): New funciton.
+
+	* faces.el (glyphless-char): New face.
+
+2010-11-01  Glenn Morris  <rgm@gnu.org>
+
+	* calendar/holidays.el (general-holidays, oriental-holidays)
+	(local-holidays, other-holidays, hebrew-holidays, christian-holidays)
+	(islamic-holidays, bahai-holidays, solar-holidays): Move aliases before
+	the definitions of their targets.
+
+	* emacs-lisp/smie.el (smie): New custom group.
+	(smie-blink-matching-inners, smie-indent-basic): Add :group.
+
+	* faces.el (xw-defined-colors, x-setup-function-keys):
+	* mouse-sel.el (x-select-text):
+	* term/w32console.el (x-setup-function-keys): Update declarations.
+
+	* progmodes/ruby-mode.el (ruby-syntax-propertize-heredoc): Declare.
+
+	* textmodes/ispell.el (comment-add): Declare.
+
+	* net/gnutls.el (gnutls-boot, gnutls-errorp, gnutls-error-string):
+	Declare.
+
+	* info.el (finder-keywords-hash, package-alist): Declare.
+
+2010-11-01  Chong Yidong  <cyd@stupidchicken.com>
+
+	* finder.el (finder-compile-keywords): Don't use intern-soft,
+	since package names may not yet exist in the obarray.
+
+2010-11-01  Chong Yidong  <cyd@stupidchicken.com>
+
+	* vc/vc-arch.el (vc-arch-checkin):
+	* vc/vc-cvs.el (vc-cvs-checkin):
+	* vc/vc-mtn.el (vc-mtn-checkin):
+	* vc/vc-rcs.el (vc-rcs-checkin):
+	* vc/vc-sccs.el (vc-sccs-checkin):
+	* vc/vc-svn.el (vc-svn-checkin): Remove optional extra arg, unused
+	since 2010-04-21 commit by Stefan Monnier.
+
+2010-11-01  Glenn Morris  <rgm@gnu.org>
+
+	* emacs-lisp/bytecomp.el (byte-recompile-file): Fix previous change.
+
+	* startup.el (package-enable-at-startup, package-initialize):
+	Silence compiler.
+
+	* progmodes/ada-mode.el (ada-font-lock-syntactic-keywords):
+	Silence compiler.
+
+2010-10-31  Julien Danjou  <julien@danjou.info>
+
+	* emacs-lisp/bytecomp.el (byte-recompile-file): New fun (bug#7297).
+	(byte-recompile-directory):
+	* emacs-lisp/lisp-mode.el (emacs-lisp-byte-compile-and-load):
+	Use `byte-recompile-file'.
+
+2010-10-31  Glenn Morris  <rgm@gnu.org>
+
+	* cus-start.el: Handle standard values via a keyword.
+	Only set version property if specified.
+	(cursor-in-non-selected-windows, menu-bar-mode)
+	(tool-bar-mode, show-trailing-whitespace):
+	Do not specify standard values.
+	(transient-mark-mode, temporary-file-directory): Use :standard.
+
+2010-10-31  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* term/x-win.el (x-get-selection-value): New function that gets
+	PRIMARY with type as specified in x-select-request-type. (Bug#6802).
+
+2010-10-31  Michael Albinus  <michael.albinus@gmx.de>
+
+	* net/tramp.el (tramp-handle-insert-file-contents): For root,
+	preserve owner and group when editing files.  (Bug#7289)
+
+2010-10-31  Glenn Morris  <rgm@gnu.org>
+
+	* speedbar.el (speedbar-mode):
+	* play/fortune.el (fortune-in-buffer, fortune):
+	* play/gomoku.el (gomoku-mode):
+	* play/landmark.el (lm-mode):
+	* textmodes/bibtex.el (bibtex-validate, bibtex-validate-globally):
+	Replace inappropriate uses of toggle-read-only.  (Bug#7292)
+
+	* select.el (x-selection): Mark it as an obsolete alias.
+
+2010-10-31  Aaron S. Hawley  <aaron.s.hawley@gmail.com>
+
+	* vc/add-log.el (find-change-log): Use derived-mode-p rather than
+	major-mode (bug#7284).
+
+2010-10-31  Glenn Morris  <rgm@gnu.org>
+
+	* menu-bar.el (menu-bar-files-menu): Make it into an actual alias,
+	rather than just an unused variable that inherits from the real one.
+
+2010-10-31  Alan Mackenzie  <acm@muc.de>
+
+	* progmodes/cc-cmds.el (c-mask-paragraph): Fix an off-by-1 error.
+	This fixes bug #7185.
+
+2010-10-30  Chong Yidong  <cyd@stupidchicken.com>
+
+	* startup.el (command-line): Search for package directories, and
+	don't load package.el if none are found.
+
+	* emacs-lisp/package.el (describe-package, list-packages): Call
+	package-initialize if it has not been called yet.
+
+2010-10-30  Alan Mackenzie  <acm@muc.de>
+
+	* progmodes/cc-fonts.el (c-font-lock-enum-tail): New function
+	which fontifies the tail of an enum.
+	(c-basic-matchers-after): Insert a call to the above new function.
+	This fixes bug #7264.
+
+2010-10-30  Glenn Morris  <rgm@gnu.org>
+
+	* cus-start.el: Add :set properties for minor modes menu-bar-mode,
+	tool-bar-mode, transient-mark-mode.  (Bug#7306)
+	Include the :set property in the dumped Emacs.
+
+2010-10-29  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	SMIE: change indent rules format, improve smie-setup.
+	* emacs-lisp/smie.el (smie-precs-precedence-table)
+	(smie-merge-prec2s, smie-bnf-precedence-table, smie-prec2-levels):
+	Mark them pure so the tables gets built at compile time.
+	(smie-bnf-precedence-table): Store the closer-alist in the table.
+	(smie-prec2-levels): Preserve the closer-alist.
+	(smie-blink-matching-open): Be more forgiving in case of indentation.
+	(smie-hanging-p): Rename from smie-indent--hanging-p.
+	(smie-bolp): Rename from smie-indent--bolp.
+	(smie--parent, smie--after): New dynamic vars.
+	(smie-parent-p, smie-next-p, smie-prev-p): New funs.
+	(smie-indent-rules): Remove.
+	(smie-indent--offset-rule): Remove fun.
+	(smie-rules-function): New var.
+	(smie-indent--rule): New fun.
+	(smie-indent--offset, smie-indent-keyword, smie-indent-after-keyword)
+	(smie-indent-exps): Use it.
+	(smie-setup): Setup paren blinking; add keyword args for token
+	functions; extract closer-alist from op-levels.
+	(smie-indent-debug-log): Remove var.
+	(smie-indent-debug): Remove fun.
+	* progmodes/prolog.el (prolog-smie-indent-rules): Remove.
+	(prolog-smie-rules): New fun to replace it.
+	(prolog-mode-variables): Simplify.
+	* progmodes/octave-mod.el (octave-smie-closer-alist): Remove, now that
+	it's setup automatically.
+	(octave-smie-indent-rules): Remove.
+	(octave-smie-rules): New fun to replace it.
+	(octave-mode): Simplify.
+
+2010-10-29  Glenn Morris  <rgm@gnu.org>
+
+	* files.el (temporary-file-directory): Remove (already defined in C).
+	* cus-start.el: Add temporary-file-directory.
+
+	* abbrev.el (abbrev-mode):
+	* composite.el (auto-composition-mode):
+	* menu-bar.el (menu-bar-mode):
+	* simple.el (transient-mark-mode):
+	* tool-bar.el (tool-bar-mode): Adjust the define-minor-mode calls so
+	that they do not define the associated variables twice.
+	* simple.el (transient-mark-mode): Remove defvar.
+	* composite.el (auto-composition-mode): Make variable auto-buffer-local.
+	* cus-start.el: Add transient-mark-mode, menu-bar-mode, tool-bar-mode.
+	Handle multiple groups, and also custom-delayed-init-variables.
+	* emacs-lisp/easy-mmode.el (define-minor-mode): Doc fix.
+
+2010-10-29  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* emacs-lisp/pcase.el (pcase): New `string' and `guard' patterns.
+	(pcase-if): Add one minor optimization.
+	(pcase-split-equal): Rename from pcase-split-eq.
+	(pcase-split-member): Rename from pcase-split-memq.
+	(pcase-u1): Add strings to the member optimization.
+	Add `guard' variant of predicates.
+	(pcase-q1): Add string patterns.
+
+2010-10-28  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* vc/log-edit.el (log-edit-rewrite-fixes): State its safety pred.
+
+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 +1204,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 +1216,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 +1268,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 +1310,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 +1339,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 +1361,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 +1369,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 +1458,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 +1539,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 +1550,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 +1600,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 +1617,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 +1632,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 +1654,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 +1690,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 +1722,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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/ChangeLog.1	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/ChangeLog.12	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/ChangeLog.7	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/ChangeLog.8	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/ChangeLog.9	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/Makefile.in	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/abbrev.el	Mon Nov 08 14:19:54 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
@@ -57,18 +57,10 @@
   "Toggle Abbrev mode in the current buffer.
 With optional argument ARG, turn abbrev mode on if ARG is
 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.
+abbreviation causes it to expand and be replaced by its expansion."
+  ;; It's defined in C, this stops the d-m-m macro defining it again.
+  :variable abbrev-mode)
 
-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 +919,4 @@
 
 (provide 'abbrev)
 
-;; arch-tag: dbd6f3ae-dfe3-40ba-b00f-f9e3ff960df5
 ;;; abbrev.el ends here
--- a/lisp/arc-mode.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/arc-mode.el	Mon Nov 08 14:19:54 2010 +0900
@@ -616,7 +616,7 @@
 (defun archive-get-lineno ()
   (if (>= (point) archive-file-list-start)
       (count-lines archive-file-list-start
-		   (save-excursion (beginning-of-line) (point)))
+		   (line-beginning-position))
     0))
 
 (defun archive-get-descr (&optional noerror)
@@ -2213,5 +2213,4 @@
 
 (provide 'arc-mode)
 
-;; arch-tag: e5966a01-35ec-4f27-8095-a043a79b457b
 ;;; arc-mode.el ends here
--- a/lisp/avoid.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/avoid.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/bindings.el	Mon Nov 08 14:19:54 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/bookmark.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/bookmark.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,8 @@
 ;;; bookmark.el --- set bookmarks, maybe annotate them, jump to them later
 
-;; Copyright (C) 1993, 1994, 1995, 1996, 1997, 2001, 2002, 2003,
-;;   2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1994, 1995, 1996, 1997, 2001, 2002, 2003, 2004,
+;;   2005, 2006, 2007, 2008, 2009, 2010
+;;   Free Software Foundation, Inc.
 
 ;; Author: Karl Fogel <kfogel@red-bean.com>
 ;; Maintainer: Karl Fogel <kfogel@red-bean.com>
@@ -816,7 +817,7 @@
   "Kill from point to end of line.
 If optional arg NEWLINE-TOO is non-nil, delete the newline too.
 Does not affect the kill ring."
-  (let ((eol (save-excursion (end-of-line) (point))))
+  (let ((eol (line-end-position)))
     (delete-region (point) eol)
     (if (and newline-too (looking-at "\n"))
         (delete-char 1))))
@@ -1684,7 +1685,7 @@
            (while (< (point) (point-max))
              (let ((bmrk (bookmark-bmenu-bookmark)))
                (push bmrk bookmark-bmenu-hidden-bookmarks)
-               (let ((start (save-excursion (end-of-line) (point))))
+               (let ((start (line-end-position)))
                  (move-to-column bookmark-bmenu-file-column t)
                  ;; Strip off `mouse-face' from the white spaces region.
                  (if (display-mouse-p)
@@ -2225,5 +2226,4 @@
 
 (provide 'bookmark)
 
-;; arch-tag: 139f519a-dd0c-4b8d-8b5d-f9fcf53ca8f6
 ;;; bookmark.el ends here
--- a/lisp/calc/calc-alg.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/calc/calc-alg.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/calc/calcalg2.el	Mon Nov 08 14:19:54 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/calendar/holidays.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/calendar/holidays.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,8 @@
 ;;; holidays.el --- holiday functions for the calendar package
 
 ;; Copyright (C) 1989, 1990, 1992, 1993, 1994, 1997, 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.
 
 ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu>
 ;; Maintainer: Glenn Morris <rgm@gnu.org>
@@ -43,6 +44,9 @@
 ;; explicitly load this file.
 
 ;;;###autoload
+(define-obsolete-variable-alias 'general-holidays
+  'holiday-general-holidays "23.1")
+;;;###autoload
 (defcustom holiday-general-holidays
   (mapcar 'purecopy
   '((holiday-fixed 1 1 "New Year's Day")
@@ -68,10 +72,10 @@
   :group 'holidays)
 ;;;###autoload
 (put 'holiday-general-holidays 'risky-local-variable t)
+
 ;;;###autoload
-(define-obsolete-variable-alias 'general-holidays
-  'holiday-general-holidays "23.1")
-
+(define-obsolete-variable-alias 'oriental-holidays
+  'holiday-oriental-holidays "23.1")
 ;;;###autoload
 (defcustom holiday-oriental-holidays
   (mapcar 'purecopy
@@ -93,10 +97,9 @@
   :group 'holidays)
 ;;;###autoload
 (put 'holiday-oriental-holidays 'risky-local-variable t)
+
 ;;;###autoload
-(define-obsolete-variable-alias 'oriental-holidays
-  'holiday-oriental-holidays "23.1")
-
+(define-obsolete-variable-alias 'local-holidays 'holiday-local-holidays "23.1")
 ;;;###autoload
 (defcustom holiday-local-holidays nil
   "Local holidays.
@@ -105,9 +108,9 @@
   :group 'holidays)
 ;;;###autoload
 (put 'holiday-local-holidays 'risky-local-variable t)
+
 ;;;###autoload
-(define-obsolete-variable-alias 'local-holidays 'holiday-local-holidays "23.1")
-
+(define-obsolete-variable-alias 'other-holidays 'holiday-other-holidays "23.1")
 ;;;###autoload
 (defcustom holiday-other-holidays nil
   "User defined holidays.
@@ -116,8 +119,6 @@
   :group 'holidays)
 ;;;###autoload
 (put 'holiday-other-holidays 'risky-local-variable t)
-;;;###autoload
-(define-obsolete-variable-alias 'other-holidays 'holiday-other-holidays "23.1")
 
 ;;;###autoload
 (defvar hebrew-holidays-1
@@ -219,6 +220,9 @@
 (make-obsolete-variable 'hebrew-holidays-4 'hebrew-holidays "23.1")
 
 ;;;###autoload
+(define-obsolete-variable-alias 'hebrew-holidays
+  'holiday-hebrew-holidays "23.1")
+;;;###autoload
 (defcustom holiday-hebrew-holidays
   (mapcar 'purecopy
   '((holiday-hebrew-passover)
@@ -235,10 +239,10 @@
   :group 'holidays)
 ;;;###autoload
 (put 'holiday-hebrew-holidays 'risky-local-variable t)
+
 ;;;###autoload
-(define-obsolete-variable-alias 'hebrew-holidays
-  'holiday-hebrew-holidays "23.1")
-
+(define-obsolete-variable-alias 'christian-holidays
+  'holiday-christian-holidays "23.1")
 ;;;###autoload
 (defcustom holiday-christian-holidays
   (mapcar 'purecopy
@@ -257,10 +261,10 @@
   :group 'holidays)
 ;;;###autoload
 (put 'holiday-christian-holidays 'risky-local-variable t)
+
 ;;;###autoload
-(define-obsolete-variable-alias 'christian-holidays
-  'holiday-christian-holidays "23.1")
-
+(define-obsolete-variable-alias 'islamic-holidays
+  'holiday-islamic-holidays "23.1")
 ;;;###autoload
 (defcustom holiday-islamic-holidays
   (mapcar 'purecopy
@@ -281,10 +285,9 @@
   :group 'holidays)
 ;;;###autoload
 (put 'holiday-islamic-holidays 'risky-local-variable t)
+
 ;;;###autoload
-(define-obsolete-variable-alias 'islamic-holidays
-  'holiday-islamic-holidays "23.1")
-
+(define-obsolete-variable-alias 'bahai-holidays 'holiday-bahai-holidays "23.1")
 ;;;###autoload
 (defcustom holiday-bahai-holidays
   (mapcar 'purecopy
@@ -305,9 +308,9 @@
   :group 'holidays)
 ;;;###autoload
 (put 'holiday-bahai-holidays 'risky-local-variable t)
+
 ;;;###autoload
-(define-obsolete-variable-alias 'bahai-holidays 'holiday-bahai-holidays "23.1")
-
+(define-obsolete-variable-alias 'solar-holidays 'holiday-solar-holidays "23.1")
 ;;;###autoload
 (defcustom holiday-solar-holidays
   (mapcar 'purecopy
@@ -328,8 +331,6 @@
   :group 'holidays)
 ;;;###autoload
 (put 'holiday-solar-holidays 'risky-local-variable t)
-;;;###autoload
-(define-obsolete-variable-alias 'solar-holidays 'holiday-solar-holidays "23.1")
 
 ;; This one should not be autoloaded, else .emacs changes of
 ;; holiday-general-holidays etc have no effect.
@@ -919,5 +920,4 @@
 
 (provide 'holidays)
 
-;; arch-tag: 48eb3117-75a7-4dbe-8fd9-873c3cbb0d37
 ;;; holidays.el ends here
--- a/lisp/cedet/ChangeLog	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/cedet/ChangeLog	Mon Nov 08 14:19:54 2010 +0900
@@ -1,3 +1,35 @@
+2010-11-07  Glenn Morris  <rgm@gnu.org>
+
+	* ede/proj-elisp.el (ede-proj-flush-autoconf): Use point-at-bol.
+
+2010-11-01  Glenn Morris  <rgm@gnu.org>
+
+	* semantic/bovine/c.el (semantic-analyze-split-name): Move before use.
+
+	* semantic/symref/cscope.el (ede-toplevel):
+	* semantic/symref.el (ede-toplevel):
+	* semantic/tag-file.el (ede-toplevel):
+	* ede.el (ede-toplevel): Fix declarations.
+
+2010-10-31  Glenn Morris  <rgm@gnu.org>
+
+	* ede/proj-elisp.el (project-compile-target): Fix previous change.
+	* semantic/ede-grammar.el (project-compile-target): Fix previous change.
+
+2010-10-31  Julien Danjou  <julien@danjou.info>
+
+	* ede/proj-elisp.el (project-compile-target):
+	* semantic/ede-grammar.el (project-compile-target):
+	Use `byte-recompile-file'.
+
+2010-10-31  Glenn Morris  <rgm@gnu.org>
+
+	* mode-local.el (mode-local-augment-function-help):
+	* semantic/analyze/debug.el (semantic-analyzer-debug-add-buttons):
+	* semantic/symref/list.el (semantic-symref-results-dump)
+	(semantic-symref-rb-toggle-expand-tag): Replace inappropriate uses
+	of toggle-read-only.
+
 2010-09-30  Chong Yidong  <cyd@stupidchicken.com>
 
 	* semantic/bovine/el.el:
--- a/lisp/cedet/ede.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/cedet/ede.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,7 @@
 ;;; ede.el --- Emacs Development Environment gloss
 
-;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-;;   2007, 2008, 2009, 2010  Free Software Foundation, Inc.
+;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007,
+;;   2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <zappo@gnu.org>
 ;; Keywords: project, make
@@ -56,7 +56,7 @@
 (declare-function ede-directory-project-p "ede/files")
 (declare-function ede-find-subproject-for-directory "ede/files")
 (declare-function ede-project-directory-remove-hash "ede/files")
-(declare-function ede-toplevel "ede/files")
+(declare-function ede-toplevel "ede/base")
 (declare-function ede-toplevel-project "ede/files")
 (declare-function ede-up-directory "ede/files")
 (declare-function semantic-lex-make-spp-table "semantic/lex-spp")
@@ -1278,5 +1278,4 @@
     (ede-speedbar-file-setup)
   (add-hook 'speedbar-load-hook 'ede-speedbar-file-setup))
 
-;; arch-tag: 0e1e0eba-484f-4119-abdb-30951f725705
 ;;; ede.el ends here
--- a/lisp/cedet/ede/base.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/cedet/ede/base.el	Mon Nov 08 14:19:54 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/cedet/ede/proj-elisp.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/cedet/ede/proj-elisp.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,7 @@
 ;;; ede-proj-elisp.el --- EDE Generic Project Emacs Lisp support
 
-;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-;;   2007, 2008, 2009, 2010  Free Software Foundation, Inc.
+;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007,
+;;   2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <zappo@gnu.org>
 ;; Keywords: project, make
@@ -129,18 +129,13 @@
 	 (utd 0))
     (mapc (lambda (src)
 	    (let* ((fsrc (expand-file-name src dir))
-		   (elc (concat (file-name-sans-extension fsrc) ".elc"))
-		   )
-	      (if (or (not (file-exists-p elc))
-		      (file-newer-than-file-p fsrc elc))
-		  (progn
-		    (setq comp (1+ comp))
-		    (byte-compile-file fsrc))
+		   (elc (concat (file-name-sans-extension fsrc) ".elc")))
+	      (if (eq (byte-recompile-file fsrc nil 0) t)
+                  (setq comp (1+ comp))
 		(setq utd (1+ utd)))))
 	    (oref obj source))
     (message "All Emacs Lisp sources are up to date in %s" (object-name obj))
-    (cons comp utd)
-    ))
+    (cons comp utd)))
 
 (defmethod ede-update-version-in-source ((this ede-proj-target-elisp) version)
   "In a Lisp file, updated a version string for THIS to VERSION.
@@ -250,10 +245,7 @@
 	    (let ((path (match-string 1)))
 	      (if (string= path "nil")
 		  nil
-		(delete-region (save-excursion (beginning-of-line) (point))
-			       (save-excursion (end-of-line)
-					       (forward-char 1)
-					       (point))))))))))
+		(delete-region (point-at-bol) (point-at-bol 2)))))))))
 
 ;;;
 ;; Autoload generators
@@ -390,5 +382,4 @@
 
 (provide 'ede/proj-elisp)
 
-;; arch-tag: 3802c94b-d04d-4ecf-9bab-b29ed6e77588
 ;;; ede/proj-elisp.el ends here
--- a/lisp/cedet/mode-local.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/cedet/mode-local.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,6 +1,7 @@
 ;;; mode-local.el --- Support for mode local facilities
 ;;
-;; Copyright (C) 2004, 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2004, 2005, 2007, 2008, 2009, 2010
+;;   Free Software Foundation, Inc.
 ;;
 ;; Author: David Ponce <david@dponce.com>
 ;; Maintainer: David Ponce <david@dponce.com>
@@ -610,19 +611,16 @@
 SYMBOL is a function that can be overridden."
   (with-current-buffer "*Help*"
     (pop-to-buffer (current-buffer))
-    (unwind-protect
-	(progn
-	  (toggle-read-only -1)
-          (goto-char (point-min))
-          (unless (re-search-forward "^$" nil t)
-            (goto-char (point-max))
-            (beginning-of-line)
-            (forward-line -1))
-          (insert (overload-docstring-extension symbol) "\n")
-	  ;; NOTE TO SELF:
-	  ;; LIST ALL LOADED OVERRIDES FOR SYMBOL HERE
-	  )
-      (toggle-read-only 1))))
+    (goto-char (point-min))
+    (unless (re-search-forward "^$" nil t)
+      (goto-char (point-max))
+      (beginning-of-line)
+      (forward-line -1))
+    (let ((inhibit-read-only t))
+      (insert (overload-docstring-extension symbol) "\n")
+      ;; NOTE TO SELF:
+      ;; LIST ALL LOADED OVERRIDES FOR SYMBOL HERE
+      )))
 
 ;; Help for mode-local bindings.
 (defun mode-local-print-binding (symbol)
@@ -782,5 +780,4 @@
 
 (provide 'mode-local)
 
-;; arch-tag: 14b77823-f93c-4b3d-9116-495f69a6ec07
 ;;; mode-local.el ends here
--- a/lisp/cedet/semantic/analyze/debug.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/cedet/semantic/analyze/debug.el	Mon Nov 08 14:19:54 2010 +0900
@@ -586,34 +586,28 @@
     (set-marker orig-buffer (point) (current-buffer))
     ;; Get a buffer ready.
     (with-current-buffer "*Help*"
-      (toggle-read-only -1)
-      (goto-char (point-min))
-      (set (make-local-variable 'semantic-analyzer-debug-orig) orig-buffer)
-      ;; First, add do-in buttons to recommendations.
-      (while (re-search-forward "^\\s-*M-x \\(\\(\\w\\|\\s_\\)+\\) " nil t)
-	(let ((fcn (match-string 1)))
-	  (when (not (fboundp (intern-soft fcn)))
-	    (error "Help Err: Can't find %s" fcn))
-	  (end-of-line)
-	  (insert "   ")
-	  (insert-button "[ Do It ]"
-			 'mouse-face 'custom-button-pressed-face
-			 'do-fcn fcn
-			 'action `(lambda (arg)
-				    (let ((M semantic-analyzer-debug-orig))
-				      (set-buffer (marker-buffer M))
-				      (goto-char M))
-				    (call-interactively (quote ,(intern-soft fcn))))
-			 )
-	  ))
+      (let ((inhibit-read-only t))
+	(goto-char (point-min))
+	(set (make-local-variable 'semantic-analyzer-debug-orig) orig-buffer)
+	;; First, add do-in buttons to recommendations.
+	(while (re-search-forward "^\\s-*M-x \\(\\(\\w\\|\\s_\\)+\\) " nil t)
+	  (let ((fcn (match-string 1)))
+	    (when (not (fboundp (intern-soft fcn)))
+	      (error "Help Err: Can't find %s" fcn))
+	    (end-of-line)
+	    (insert "   ")
+	    (insert-button "[ Do It ]"
+			   'mouse-face 'custom-button-pressed-face
+			   'do-fcn fcn
+			   'action `(lambda (arg)
+				      (let ((M semantic-analyzer-debug-orig))
+					(set-buffer (marker-buffer M))
+					(goto-char M))
+				      (call-interactively (quote ,(intern-soft fcn))))))))
       ;; Do something else?
-
       ;; Clean up the mess
-      (toggle-read-only 1)
-      (set-buffer-modified-p nil)
-      )))
+      (set-buffer-modified-p nil))))
 
 (provide 'semantic/analyze/debug)
 
-;; arch-tag: 943db1e5-47e6-4bec-9989-78ebfadf0358
 ;;; semantic/analyze/debug.el ends here
--- a/lisp/cedet/semantic/bovine/c.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/cedet/semantic/bovine/c.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1002,6 +1002,13 @@
 where typename is the name of the type, and typeoftype is \"class\"
 or \"struct\".")
 
+(define-mode-local-override semantic-analyze-split-name c-mode (name)
+  "Split up tag names on colon (:) boundaries."
+  (let ((ans (split-string name ":")))
+    (if (= (length ans) 1)
+	name
+      (delete "" ans))))
+
 (defun semantic-c-reconstitute-token (tokenpart declmods typedecl)
   "Reconstitute a token TOKENPART with DECLMODS and TYPEDECL.
 This is so we don't have to match the same starting text several times.
@@ -1559,13 +1566,6 @@
 	   (string= (semantic-tag-type type) "enum"))
       (semantic-tag-type-members type)))
 
-(define-mode-local-override semantic-analyze-split-name c-mode (name)
-  "Split up tag names on colon (:) boundaries."
-  (let ((ans (split-string name ":")))
-    (if (= (length ans) 1)
-	name
-      (delete "" ans))))
-
 (define-mode-local-override semantic-analyze-unsplit-name c-mode (namelist)
   "Assemble the list of names NAMELIST into a namespace name."
   (mapconcat 'identity namelist "::"))
@@ -1871,5 +1871,4 @@
 ;; generated-autoload-load-name: "semantic/bovine/c"
 ;; End:
 
-;; arch-tag: 263951a8-0f18-445d-8e73-eb8f9ac8e2a3
 ;;; semantic/bovine/c.el ends here
--- a/lisp/cedet/semantic/ede-grammar.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/cedet/semantic/ede-grammar.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,6 +1,7 @@
 ;;; semantic/ede-grammar.el --- EDE support for Semantic Grammar Files
 
-;;;  Copyright (C) 2003, 2004, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2004, 2007, 2008, 2009, 2010
+;;   Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <zappo@gnu.org>
 ;; Keywords: project, make
@@ -133,11 +134,8 @@
 	      (save-excursion
 		(semantic-grammar-create-package))
 	      (save-buffer)
-	      (let ((cf (concat (semantic-grammar-package) ".el")))
-		(if (or (not (file-exists-p cf))
-			(file-newer-than-file-p src cf))
-		    (byte-compile-file cf)))))
-	    (oref obj source)))
+              (byte-recompile-file (concat (semantic-grammar-package) ".el") nil 0)))
+	  (oref obj source)))
   (message "All Semantic Grammar sources are up to date in %s" (object-name obj)))
 
 ;;; Makefile generation functions
@@ -197,5 +195,4 @@
 
 (provide 'semantic/ede-grammar)
 
-;; arch-tag: 37a06a8d-957a-4fa2-a931-38482d28c24a
 ;;; semantic/ede-grammar.el ends here
--- a/lisp/cedet/semantic/symref.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/cedet/semantic/symref.el	Mon Nov 08 14:19:54 2010 +0900
@@ -69,7 +69,7 @@
 (defvar ede-minor-mode)
 (declare-function data-debug-new-buffer "data-debug")
 (declare-function data-debug-insert-object-slots "eieio-datadebug")
-(declare-function ede-toplevel "ede/files")
+(declare-function ede-toplevel "ede/base")
 (declare-function ede-project-root-directory "ede/files")
 (declare-function ede-up-directory "ede/files")
 
@@ -508,5 +508,4 @@
 ;; generated-autoload-load-name: "semantic/symref"
 ;; End:
 
-;; arch-tag: 928394b7-19ef-4f76-8cb3-37e9a9891984
 ;;; semantic/symref.el ends here
--- a/lisp/cedet/semantic/symref/cscope.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/cedet/semantic/symref/cscope.el	Mon Nov 08 14:19:54 2010 +0900
@@ -27,7 +27,7 @@
 (require 'semantic/symref)
 
 (defvar ede-minor-mode)
-(declare-function ede-toplevel "ede/files")
+(declare-function ede-toplevel "ede/base")
 (declare-function ede-project-root-directory "ede/files")
 
 ;;; Code:
@@ -91,5 +91,4 @@
 ;; generated-autoload-load-name: "semantic/symref/cscope"
 ;; End:
 
-;; arch-tag: 7c0a4e02-ade4-407a-9df7-4f948bd61a19
 ;;; semantic/symref/cscope.el ends here
--- a/lisp/cedet/semantic/symref/list.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/cedet/semantic/symref/list.el	Mon Nov 08 14:19:54 2010 +0900
@@ -221,49 +221,38 @@
 (defun semantic-symref-results-dump (results)
   "Dump the RESULTS into the current buffer."
   ;; Get ready for the insert.
-  (toggle-read-only -1)
-  (erase-buffer)
-
-  ;; Insert the contents.
-  (let ((lastfile nil)
-	)
-    (dolist (T (oref results :hit-tags))
-
-      (when (not (equal lastfile (semantic-tag-file-name T)))
-	(setq lastfile (semantic-tag-file-name T))
-	(insert-button lastfile
-		       'mouse-face 'custom-button-pressed-face
-		       'action 'semantic-symref-rb-goto-file
+  (let ((inhibit-read-only t))
+    (erase-buffer)
+    ;; Insert the contents.
+    (let ((lastfile nil))
+      (dolist (T (oref results :hit-tags))
+	(unless (equal lastfile (semantic-tag-file-name T))
+	  (setq lastfile (semantic-tag-file-name T))
+	  (insert-button lastfile
+			 'mouse-face 'custom-button-pressed-face
+			 'action 'semantic-symref-rb-goto-file
+			 'tag T)
+	  (insert "\n"))
+	(insert "  ")
+	(insert-button "[+]"
+		       'mouse-face 'highlight
+		       'face nil
+		       'action 'semantic-symref-rb-toggle-expand-tag
 		       'tag T
-		       )
-	(insert "\n"))
-
-      (insert "  ")
-      (insert-button "[+]"
-		     'mouse-face 'highlight
-		     'face nil
-		     'action 'semantic-symref-rb-toggle-expand-tag
-		     'tag T
-		     'state 'closed)
-      (insert " ")
-      (insert-button (funcall semantic-symref-results-summary-function
-			      T nil t)
-		     'mouse-face 'custom-button-pressed-face
-		     'face nil
-		     'action 'semantic-symref-rb-goto-tag
-		     'tag T)
-      (insert "\n")
-
-      ))
-
-  ;; Auto expand
-  (when semantic-symref-auto-expand-results
-    (semantic-symref-list-expand-all))
-
-  ;; Clean up the mess
-  (toggle-read-only 1)
-  (set-buffer-modified-p nil)
-  )
+		       'state 'closed)
+	(insert " ")
+	(insert-button (funcall semantic-symref-results-summary-function
+				T nil t)
+		       'mouse-face 'custom-button-pressed-face
+		       'face nil
+		       'action 'semantic-symref-rb-goto-tag
+		       'tag T)
+	(insert "\n")))
+    ;; Auto expand
+    (when semantic-symref-auto-expand-results
+      (semantic-symref-list-expand-all)))
+    ;; Clean up the mess
+  (set-buffer-modified-p nil))
 
 ;;; Commands for semantic-symref-results
 ;;
@@ -283,11 +272,9 @@
 	 (buff (semantic-tag-buffer tag))
 	 (hits (semantic--tag-get-property tag :hit))
 	 (state (button-get button 'state))
-	 (text nil)
-	 )
+	 (text nil))
     (cond
      ((eq state 'closed)
-      (toggle-read-only -1)
       (with-current-buffer buff
 	(dolist (H hits)
 	  (goto-char (point-min))
@@ -295,48 +282,42 @@
 	  (beginning-of-line)
 	  (back-to-indentation)
 	  (setq text (cons (buffer-substring (point) (point-at-eol)) text)))
-	(setq text (nreverse text))
-	)
+	(setq text (nreverse text)))
       (goto-char (button-start button))
       (forward-char 1)
-      (delete-char 1)
-      (insert "-")
-      (button-put button 'state 'open)
-      (save-excursion
-	(end-of-line)
-	(while text
-	(insert "\n")
-	  (insert "    ")
-	  (insert-button (car text)
-			 'mouse-face 'highlight
-			 'face nil
-			 'action 'semantic-symref-rb-goto-match
-			 'tag tag
-			 'line (car hits))
-	  (setq text (cdr text)
-		hits (cdr hits))))
-      (toggle-read-only 1)
-      )
+      (let ((inhibit-read-only t))
+	(delete-char 1)
+	(insert "-")
+	(button-put button 'state 'open)
+	(save-excursion
+	  (end-of-line)
+	  (while text
+	    (insert "\n")
+	    (insert "    ")
+	    (insert-button (car text)
+			   'mouse-face 'highlight
+			   'face nil
+			   'action 'semantic-symref-rb-goto-match
+			   'tag tag
+			   'line (car hits))
+	    (setq text (cdr text)
+		  hits (cdr hits))))))
      ((eq state 'open)
-      (toggle-read-only -1)
-      (button-put button 'state 'closed)
-      ;; Delete the various bits.
-      (goto-char (button-start button))
-      (forward-char 1)
-      (delete-char 1)
-      (insert "+")
-      (save-excursion
-	(end-of-line)
+      (let ((inhibit-read-only t))
+	(button-put button 'state 'closed)
+	;; Delete the various bits.
+	(goto-char (button-start button))
 	(forward-char 1)
-	(delete-region (point)
-		       (save-excursion
-			 (forward-char 1)
-			 (forward-line (length hits))
-			 (point))))
-      (toggle-read-only 1)
-      )
-     ))
-  )
+	(delete-char 1)
+	(insert "+")
+	(save-excursion
+	  (end-of-line)
+	  (forward-char 1)
+	  (delete-region (point)
+			 (save-excursion
+			   (forward-char 1)
+			   (forward-line (length hits))
+			   (point)))))))))
 
 (defun semantic-symref-rb-goto-file (&optional button)
   "Go to the file specified in the symref results buffer.
@@ -554,5 +535,4 @@
 ;; generated-autoload-load-name: "semantic/symref/list"
 ;; End:
 
-;; arch-tag: e355d9c6-26e0-42d1-9bf1-f4801a54fffa
 ;;; semantic/symref/list.el ends here
--- a/lisp/cedet/semantic/tag-file.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/cedet/semantic/tag-file.el	Mon Nov 08 14:19:54 2010 +0900
@@ -32,7 +32,7 @@
 (declare-function semanticdb-table-child-p "semantic/db" t t)
 (declare-function semanticdb-get-buffer "semantic/db")
 (declare-function semantic-dependency-find-file-on-path "semantic/dep")
-(declare-function ede-toplevel "ede/files")
+(declare-function ede-toplevel "ede/base")
 
 ;;; Code:
 
@@ -214,5 +214,4 @@
 ;; generated-autoload-load-name: "semantic/tag-file"
 ;; End:
 
-;; arch-tag: 71d4cf18-c1ec-414c-bb0a-c2ed914c1361
 ;;; semantic/tag-file.el ends here
--- a/lisp/comint.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/comint.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/composite.el	Mon Nov 08 14:19:54 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.
@@ -743,7 +743,11 @@
 by functions registered in `composition-function-table' (which see).
 
 You can use `global-auto-composition-mode' to turn on
-Auto Composition mode in all buffers (this is the default).")
+Auto Composition mode in all buffers (this is the default)."
+  ;; It's defined in C, this stops the d-m-m macro defining it again.
+  :variable auto-composition-mode)
+;; It's not defined with DEFVAR_PER_BUFFER though.
+(make-variable-buffer-local 'auto-composition-mode)
 
 ;;;###autoload
 (define-minor-mode global-auto-composition-mode
@@ -757,5 +761,4 @@
 
 
 
-;; arch-tag: ee703d77-1723-45d4-a31f-e9f0f867aa33
 ;;; composite.el ends here
--- a/lisp/cus-edit.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/cus-edit.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/cus-face.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/cus-start.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,7 @@
 ;;; cus-start.el --- define customization properties of builtins
 ;;
-;; Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+;;   2007, 2008, 2009, 2010  Free Software Foundation, Inc.
 ;;
 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
 ;; Keywords: internal
@@ -34,6 +34,19 @@
 
 ;;; Code:
 
+;; Elements of this list have the form:
+;; SYMBOL GROUP TYPE VERSION REST...
+;; SYMBOL is the name of the variable.
+;; GROUP is the custom group to which it belongs (may also be a list
+;; of groups)
+;; TYPE is the defcustom :type.
+;; VERSION is the defcustom :version (or nil).
+;; REST is a set of :KEYWORD VALUE pairs.  Accepted :KEYWORDs are:
+;; :standard - standard value for SYMBOL (else use current value)
+;; :set - custom-set property
+;; :risky - risky-local-variable property
+;; :safe - safe-local-variable property
+;; :tag - custom-tag property
 (let ((all '(;; alloc.c
 	     (gc-cons-threshold alloc integer)
 	     (garbage-collection-messages alloc boolean)
@@ -96,6 +109,16 @@
 				       "21.1")
 	     (line-spacing display (choice (const :tag "none" nil) integer)
 			   "22.1")
+	     (cursor-in-non-selected-windows
+	      cursor boolean nil
+	      :tag "Cursor In Non-selected Windows"
+	      :set #'(lambda (symbol value)
+		       (set-default symbol value)
+		       (force-mode-line-update t)))
+	     (transient-mark-mode editing-basics boolean nil
+				  :standard (not noninteractive)
+				  :initialize custom-initialize-delay
+				  :set custom-set-minor-mode)
 	     ;; callint.c
 	     (mark-even-if-inactive editing-basics boolean)
 	     ;; callproc.c
@@ -166,6 +189,36 @@
              ;; fileio.c
              (delete-by-moving-to-trash auto-save boolean "23.1")
 	     (auto-save-visited-file-name auto-save boolean)
+	     ;; filelock.c
+	     (temporary-file-directory
+	      ;; Darwin section added 24.1, does not seem worth :version bump.
+	      files directory nil
+	      :standard
+	      (file-name-as-directory
+	       ;; FIXME ? Should there be Ftemporary_file_directory to do this
+	       ;; more robustly (cf set_local_socket in emacsclient.c).
+	       ;; It could be used elsewhere, eg Fcall_process_region,
+	       ;; server-socket-dir.  See bug#7135.
+	       (cond ((memq system-type '(ms-dos windows-nt))
+		      (or (getenv "TEMP") (getenv "TMPDIR") (getenv "TMP")
+			  "c:/temp"))
+		     ((eq system-type 'darwin)
+		      (or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP")
+			  ;; See bug#7135.
+			  (let ((tmp (ignore-errors
+				       (shell-command-to-string
+					"getconf DARWIN_USER_TEMP_DIR"))))
+			    (and (stringp tmp)
+				 (setq tmp (replace-regexp-in-string
+					    "\n\\'" "" tmp))
+				 ;; Handles "getconf: Unrecognized variable..."
+				 (file-directory-p tmp)
+				 tmp))
+			  "/tmp"))
+		     (t
+		      (or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP")
+			  "/tmp"))))
+	      :initialize custom-initialize-delay)
 	     ;; fns.c
 	     (use-dialog-box menu boolean "21.1")
 	     (use-file-dialog menu boolean "22.1")
@@ -180,6 +233,13 @@
 					    (other :tag "hidden by keypress" 1))
 			      "22.1")
 	     (make-pointer-invisible mouse boolean "23.2")
+	     (menu-bar-mode frames boolean nil
+			    ;; FIXME?
+;			    :initialize custom-initialize-default
+			    :set custom-set-minor-mode)
+	     (tool-bar-mode (frames mouse) boolean nil
+;			    :initialize custom-initialize-default
+			    :set custom-set-minor-mode)
 	     ;; fringe.c
 	     (overflow-newline-into-fringe fringe boolean)
 	     ;; indent.c
@@ -327,6 +387,8 @@
 				  (other :tag "Always" t))
 				 "23.1")
 	     ;; xdisp.c
+	     (show-trailing-whitespace whitespace-faces boolean nil
+				       :safe booleanp)
 	     (scroll-step windows integer)
 	     (scroll-conservatively windows integer)
 	     (scroll-margin windows integer)
@@ -362,6 +424,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 +444,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)
@@ -398,12 +463,13 @@
 	  group (nth 1 this)
 	  type (nth 2 this)
 	  version (nth 3 this)
+	  rest (nthcdr 4 this)
 	  ;; If we did not specify any standard value expression above,
 	  ;; use the current value as the standard value.
-	  standard (if (nthcdr 4 this)
-		       (nth 4 this)
-		     (when (default-boundp symbol)
-		       (funcall quoter (default-value symbol))))
+	  standard (if (setq prop (memq :standard rest))
+		       (cadr prop)
+		     (if (default-boundp symbol)
+			 (funcall quoter (default-value symbol))))
 	  ;; Don't complain about missing variables which are
 	  ;; irrelevant to this platform.
 	  native-p (save-match-data
@@ -436,25 +502,44 @@
       ;; Save the standard value, unless we already did.
       (or (get symbol 'standard-value)
 	  (put symbol 'standard-value (list standard)))
-      ;; If this is NOT while dumping Emacs,
-      ;; set up the rest of the customization info.
+      ;; 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 (setq prop (memq :set rest))
+	  (put symbol 'custom-set (cadr prop)))
+      ;; Note this is the _only_ initialize property we handle.
+      (if (eq (cadr (memq :initialize rest)) 'custom-initialize-delay)
+	  (push symbol custom-delayed-init-variables))
+      ;; If this is NOT while dumping Emacs, set up the rest of the
+      ;; customization info.  This is the stuff that is not needed
+      ;; until someone does M-x customize etc.
       (unless purify-flag
-	;; Add it to the right group.
-	(custom-add-to-group group symbol 'custom-variable)
+	;; Add it to the right group(s).
+	(if (listp group)
+	    (dolist (g group)
+	      (custom-add-to-group g symbol 'custom-variable))
+	  (custom-add-to-group group symbol 'custom-variable))
 	;; Set the type.
 	(put symbol 'custom-type type)
-	(put symbol 'custom-version version)))))
+	(if version (put symbol 'custom-version version))
+	(while rest
+	  (setq prop (car rest)
+		propval (cadr rest)
+		rest (nthcdr 2 rest))
+	  (cond ((memq prop '(:standard :risky :safe :set))) ; handled above
+		((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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/cus-theme.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/custom.el	Mon Nov 08 14:19:54 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/dframe.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/dframe.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,8 @@
 ;;; dframe --- dedicate frame support modes
 
-;;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-;;    2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+;;   2005, 2006, 2007, 2008, 2009, 2010
+;;   Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <zappo@gnu.org>
 ;; Keywords: file, tags, tools
@@ -784,8 +785,8 @@
               (popup-mode-menu event)
             (goto-char (event-closest-point event))
             (beginning-of-line)
-            (forward-char (min 5 (- (save-excursion (end-of-line) (point))
-                                    (save-excursion (beginning-of-line) (point)))))
+            (forward-char (min 5 (- (line-end-position)
+                                    (line-beginning-position))))
             (popup-mode-menu))
           ;; Wait for menu to bail out.  `popup-mode-menu' (and other popup
           ;; menu functions) return immediately.
@@ -991,5 +992,4 @@
 
 (provide 'dframe)
 
-;; arch-tag: df9b91b6-e85e-4a76-a02e-b3cb5b686bd4
 ;;; dframe.el ends here
--- a/lisp/dired.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/dired.el	Mon Nov 08 14:19:54 2010 +0900
@@ -2138,7 +2138,7 @@
       ;; case-fold-search is nil now, so we can test for capital F:
       (setq used-F (string-match "F" dired-actual-switches)
 	    opoint (point)
-	    eol (save-excursion (end-of-line) (point))
+	    eol (line-end-position)
 	    hidden (and selective-display
 			(save-excursion (search-forward "\r" eol t))))
       (if hidden
@@ -4030,5 +4030,4 @@
 
 (run-hooks 'dired-load-hook)		; for your customizations
 
-;; arch-tag: e1af7a8f-691c-41a0-aac1-ddd4d3c87517
 ;;; dired.el ends here
--- a/lisp/ebuff-menu.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/ebuff-menu.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,7 @@
 ;;; ebuff-menu.el --- electric-buffer-list mode
 
-;; Copyright (C) 1985, 1986, 1994, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1986, 1994, 2001, 2002, 2003, 2004, 2005, 2006,
+;;   2007, 2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: Richard Mlynarik <mly@ai.mit.edu>
 ;; Maintainer: FSF
@@ -282,11 +282,10 @@
 	  (make-local-variable 'electric-buffer-overlay)
 	  (setq electric-buffer-overlay (make-overlay (point) (point)))))
     (move-overlay electric-buffer-overlay
-		  (save-excursion (beginning-of-line) (point))
-		  (save-excursion (end-of-line) (point)))
+		  (line-beginning-position)
+		  (line-end-position))
     (overlay-put electric-buffer-overlay 'face 'highlight)))
 
 (provide 'ebuff-menu)
 
-;; arch-tag: 1d4509b3-eece-4d4f-95ea-77c83eaf0275
 ;;; ebuff-menu.el ends here
--- a/lisp/electric.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/electric.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/emacs-lisp/autoload.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/emacs-lisp/byte-opt.el	Mon Nov 08 14:19:54 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*))
@@ -1316,35 +1316,38 @@
   "Don't call this!"
   ;; fetch and return the offset for the current opcode.
   ;; return nil if this opcode has no offset
-  ;; OP, PTR and BYTES are used and set dynamically
-  (defvar op)
-  (defvar ptr)
-  (defvar bytes)
-  (cond ((< op byte-nth)
-	 (let ((tem (logand op 7)))
-	   (setq op (logand op 248))
+  ;; Used and set dynamically in byte-decompile-bytecode-1.
+  (defvar bytedecomp-op)
+  (defvar bytedecomp-ptr)
+  (defvar bytedecomp-bytes)
+  (cond ((< bytedecomp-op byte-nth)
+	 (let ((tem (logand bytedecomp-op 7)))
+	   (setq bytedecomp-op (logand bytedecomp-op 248))
 	   (cond ((eq tem 6)
-		  (setq ptr (1+ ptr))	;offset in next byte
-		  (aref bytes ptr))
+		  ;; Offset in next byte.
+		  (setq bytedecomp-ptr (1+ bytedecomp-ptr))
+		  (aref bytedecomp-bytes bytedecomp-ptr))
 		 ((eq tem 7)
-		  (setq ptr (1+ ptr))	;offset in next 2 bytes
-		  (+ (aref bytes ptr)
-		     (progn (setq ptr (1+ ptr))
-			    (lsh (aref bytes ptr) 8))))
+		  ;; Offset in next 2 bytes.
+		  (setq bytedecomp-ptr (1+ bytedecomp-ptr))
+		  (+ (aref bytedecomp-bytes bytedecomp-ptr)
+		     (progn (setq bytedecomp-ptr (1+ bytedecomp-ptr))
+			    (lsh (aref bytedecomp-bytes bytedecomp-ptr) 8))))
 		 (t tem))))		;offset was in opcode
-	((>= op byte-constant)
-	 (prog1 (- op byte-constant)	;offset in opcode
-	   (setq op byte-constant)))
-	((and (>= op byte-constant2)
-	      (<= op byte-goto-if-not-nil-else-pop))
-	 (setq ptr (1+ ptr))		;offset in next 2 bytes
-	 (+ (aref bytes ptr)
-	    (progn (setq ptr (1+ ptr))
-		   (lsh (aref bytes ptr) 8))))
-	((and (>= op byte-listN)
-	      (<= op byte-insertN))
-	 (setq ptr (1+ ptr))		;offset in next byte
-	 (aref bytes ptr))))
+	((>= bytedecomp-op byte-constant)
+	 (prog1 (- bytedecomp-op byte-constant)	;offset in opcode
+	   (setq bytedecomp-op byte-constant)))
+	((and (>= bytedecomp-op byte-constant2)
+	      (<= bytedecomp-op byte-goto-if-not-nil-else-pop))
+	 ;; Offset in next 2 bytes.
+	 (setq bytedecomp-ptr (1+ bytedecomp-ptr))
+	 (+ (aref bytedecomp-bytes bytedecomp-ptr)
+	    (progn (setq bytedecomp-ptr (1+ bytedecomp-ptr))
+		   (lsh (aref bytedecomp-bytes bytedecomp-ptr) 8))))
+	((and (>= bytedecomp-op byte-listN)
+	      (<= bytedecomp-op byte-insertN))
+	 (setq bytedecomp-ptr (1+ bytedecomp-ptr)) ;offset in next byte
+	 (aref bytedecomp-bytes bytedecomp-ptr))))
 
 
 ;; This de-compiler is used for inline expansion of compiled functions,
@@ -1367,19 +1370,20 @@
 ;; If MAKE-SPLICEABLE is nil, we are being called for the disassembler.
 ;; In that case, we put a pc value into the list
 ;; before each insn (or its label).
-(defun byte-decompile-bytecode-1 (bytes constvec &optional make-spliceable)
-  (let ((length (length bytes))
-	(ptr 0) optr tags op offset
+(defun byte-decompile-bytecode-1 (bytedecomp-bytes constvec
+						   &optional make-spliceable)
+  (let ((length (length bytedecomp-bytes))
+	(bytedecomp-ptr 0) optr tags bytedecomp-op offset
 	lap tmp
 	endtag)
-    (while (not (= ptr length))
+    (while (not (= bytedecomp-ptr length))
       (or make-spliceable
-	  (setq lap (cons ptr lap)))
-      (setq op (aref bytes ptr)
-	    optr ptr
+	  (setq lap (cons bytedecomp-ptr lap)))
+      (setq bytedecomp-op (aref bytedecomp-bytes bytedecomp-ptr)
+	    optr bytedecomp-ptr
 	    offset (disassemble-offset)) ; this does dynamic-scope magic
-      (setq op (aref byte-code-vector op))
-      (cond ((memq op byte-goto-ops)
+      (setq bytedecomp-op (aref byte-code-vector bytedecomp-op))
+      (cond ((memq bytedecomp-op byte-goto-ops)
 	     ;; it's a pc
 	     (setq offset
 		   (cdr (or (assq offset tags)
@@ -1387,27 +1391,28 @@
 				       (cons (cons offset
 						   (byte-compile-make-tag))
 					     tags)))))))
-	    ((cond ((eq op 'byte-constant2) (setq op 'byte-constant) t)
-		   ((memq op byte-constref-ops)))
+	    ((cond ((eq bytedecomp-op 'byte-constant2)
+		    (setq bytedecomp-op 'byte-constant) t)
+		   ((memq bytedecomp-op byte-constref-ops)))
 	     (setq tmp (if (>= offset (length constvec))
 			   (list 'out-of-range offset)
 			 (aref constvec offset))
-		   offset (if (eq op 'byte-constant)
+		   offset (if (eq bytedecomp-op 'byte-constant)
 			      (byte-compile-get-constant tmp)
 			    (or (assq tmp byte-compile-variables)
 				(car (setq byte-compile-variables
 					   (cons (list tmp)
 						 byte-compile-variables)))))))
 	    ((and make-spliceable
-		  (eq op 'byte-return))
-	     (if (= ptr (1- length))
-		 (setq op nil)
+		  (eq bytedecomp-op 'byte-return))
+	     (if (= bytedecomp-ptr (1- length))
+		 (setq bytedecomp-op nil)
 	       (setq offset (or endtag (setq endtag (byte-compile-make-tag)))
-		     op 'byte-goto))))
+		     bytedecomp-op 'byte-goto))))
       ;; lap = ( [ (pc . (op . arg)) ]* )
-      (setq lap (cons (cons optr (cons op (or offset 0)))
+      (setq lap (cons (cons optr (cons bytedecomp-op (or offset 0)))
 		      lap))
-      (setq ptr (1+ ptr)))
+      (setq bytedecomp-ptr (1+ bytedecomp-ptr)))
     ;; take off the dummy nil op that we replaced a trailing "return" with.
     (let ((rest lap))
       (while rest
@@ -2036,5 +2041,4 @@
 	       byte-optimize-lapcode))))
  nil)
 
-;; arch-tag: 0f14076b-737e-4bef-aae6-908826ec1ff1
 ;;; byte-opt.el ends here
--- a/lisp/emacs-lisp/bytecomp.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/emacs-lisp/bytecomp.el	Mon Nov 08 14:19:54 2010 +0900
@@ -37,6 +37,7 @@
 ;; ========================================================================
 ;; Entry points:
 ;;	byte-recompile-directory, byte-compile-file,
+;;      byte-recompile-file,
 ;;     batch-byte-compile, batch-byte-recompile-directory,
 ;;	byte-compile, compile-defun,
 ;;	display-call-tree
@@ -1551,23 +1552,10 @@
 			(not (auto-save-file-name-p bytecomp-source))
 			(not (string-equal dir-locals-file
 					   (file-name-nondirectory
-					    bytecomp-source)))
-			(setq bytecomp-dest
-                              (byte-compile-dest-file bytecomp-source))
-			(if (file-exists-p bytecomp-dest)
-			    ;; File was already compiled.
-			    (or bytecomp-force
-                                (file-newer-than-file-p bytecomp-source
-                                                        bytecomp-dest))
-			  ;; No compiled file exists yet.
-			  (and bytecomp-arg
-			       (or (eq 0 bytecomp-arg)
-				   (y-or-n-p (concat "Compile "
-                                                     bytecomp-source "? "))))))
-		   (progn (if (and noninteractive (not byte-compile-verbose))
-			      (message "Compiling %s..." bytecomp-source))
-			  (let ((bytecomp-res (byte-compile-file
-                                               bytecomp-source)))
+					    bytecomp-source))))
+		   (progn (let ((bytecomp-res (byte-recompile-file
+                                               bytecomp-source
+                                               bytecomp-force bytecomp-arg)))
 			    (cond ((eq bytecomp-res 'no-byte-compile)
 				   (setq skip-count (1+ skip-count)))
 				  ((eq bytecomp-res t)
@@ -1595,6 +1583,60 @@
 ;; Local Variables:\n;; no-byte-compile: t\n;; End: ")
 ;;;###autoload(put 'no-byte-compile 'safe-local-variable 'booleanp)
 
+(defun byte-recompile-file (bytecomp-filename &optional bytecomp-force bytecomp-arg load)
+  "Recompile BYTECOMP-FILENAME file if it needs recompilation.
+This happens when its `.elc' file is older than itself.
+
+If the `.elc' file exists and is up-to-date, normally this
+function *does not* compile BYTECOMP-FILENAME. However, if the
+prefix argument BYTECOMP-FORCE is set, that means do compile
+BYTECOMP-FILENAME even if the destination already exists and is
+up-to-date.
+
+If the `.elc' file does not exist, normally this function *does
+not* compile BYTECOMP-FILENAME. If BYTECOMP-ARG is 0, that means
+compile the file even if it has never been compiled before.
+A nonzero BYTECOMP-ARG means ask the user.
+
+If LOAD is set, `load' the file after compiling.
+
+The value returned is the value returned by `byte-compile-file',
+or 'no-byte-compile if the file did not need recompilation."
+  (interactive
+      (let ((bytecomp-file buffer-file-name)
+	 (bytecomp-file-name nil)
+	 (bytecomp-file-dir nil))
+     (and bytecomp-file
+	  (eq (cdr (assq 'major-mode (buffer-local-variables)))
+	      'emacs-lisp-mode)
+	  (setq bytecomp-file-name (file-name-nondirectory bytecomp-file)
+		bytecomp-file-dir (file-name-directory bytecomp-file)))
+     (list (read-file-name (if current-prefix-arg
+			       "Byte compile file: "
+			     "Byte recompile file: ")
+			   bytecomp-file-dir bytecomp-file-name nil)
+	   current-prefix-arg)))
+  (let ((bytecomp-dest
+         (byte-compile-dest-file bytecomp-filename))
+        ;; Expand now so we get the current buffer's defaults
+        (bytecomp-filename (expand-file-name bytecomp-filename)))
+    (if (if (file-exists-p bytecomp-dest)
+            ;; File was already compiled
+            ;; Compile if forced to, or filename newer
+            (or bytecomp-force
+                (file-newer-than-file-p bytecomp-filename
+                                         bytecomp-dest))
+          (and bytecomp-arg
+               (or (eq 0 bytecomp-arg)
+                   (y-or-n-p (concat "Compile "
+                                     bytecomp-filename "? ")))))
+        (progn
+          (if (and noninteractive (not byte-compile-verbose))
+              (message "Compiling %s..." bytecomp-filename))
+          (byte-compile-file bytecomp-filename load))
+      (when load (load bytecomp-filename))
+      'no-byte-compile)))
+
 ;;;###autoload
 (defun byte-compile-file (bytecomp-filename &optional load)
   "Compile a file of Lisp code named BYTECOMP-FILENAME into a file of byte code.
@@ -4308,5 +4350,4 @@
 
 (run-hooks 'bytecomp-load-hook)
 
-;; arch-tag: 9c97b0f0-8745-4571-bfc3-8dceb677292a
 ;;; bytecomp.el ends here
--- a/lisp/emacs-lisp/chart.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/emacs-lisp/chart.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,7 @@
 ;;; chart.el --- Draw charts (bar charts, etc)
 
-;; Copyright (C) 1996, 1998, 1999, 2001, 2004, 2005, 2007, 2008, 2009, 2010
-;;   Free Software Foundation, Inc.
+;; Copyright (C) 1996, 1998, 1999, 2001, 2004, 2005, 2007, 2008, 2009,
+;;   2010  Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam  <zappo@gnu.org>
 ;; Version: 0.2
@@ -525,9 +525,9 @@
 (defun chart-zap-chars (n)
   "Zap up to N chars without deleting EOLs."
   (if (not (eobp))
-      (if (< n (- (save-excursion (end-of-line) (point)) (point)))
+      (if (< n (- (point-at-eol) (point)))
 	  (delete-char n)
-	(delete-region (point) (save-excursion (end-of-line) (point))))))
+	(delete-region (point) (point-at-eol)))))
 
 (defun chart-display-label (label dir zone start end &optional face)
   "Display LABEL in direction DIR in column/row ZONE between START and END.
@@ -746,5 +746,4 @@
 
 (provide 'chart)
 
-;; arch-tag: 43847e44-5b45-465e-adc9-e505490a6b59
 ;;; chart.el ends here
--- a/lisp/emacs-lisp/checkdoc.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/emacs-lisp/checkdoc.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1366,7 +1366,7 @@
 			   (setq checkdoc-autofix-flag 'never))))
 		 (checkdoc-create-error
 		  "You should convert this comment to documentation"
-		  (point) (save-excursion (end-of-line) (point))))
+		  (point) (line-end-position)))
 	     (checkdoc-create-error
 	      (if (nth 2 fp)
 		  "All interactive functions should have documentation"
@@ -1388,7 +1388,7 @@
 regexp short cuts work.  FP is the function defun information."
   (let ((case-fold-search nil)
 	;; Use a marker so if an early check modifies the text,
-	;; we won't accidentally loose our place.  This could cause
+	;; we won't accidentally lose our place.  This could cause
 	;; end-of doc string whitespace to also delete the " char.
 	(s (point))
 	(e (if (looking-at "\"")
@@ -1486,12 +1486,10 @@
 		    "First line not a complete sentence.  Add RET here? "
 		    "\n" t)
 		   (let (l1 l2)
-		     (forward-line 1)
-		     (end-of-line)
+		     (end-of-line 2)
 		     (setq l1 (current-column)
 			   l2 (save-excursion
-				(forward-line 1)
-				(end-of-line)
+				(end-of-line 2)
 				(current-column)))
 		     (if (> (+ l1 l2 1) 80)
 			 (setq msg "Incomplete auto-fix; doc string \
@@ -1508,10 +1506,7 @@
 	       (forward-line 1)
 	       (beginning-of-line)
 	       (if (and (re-search-forward "[.!?:\"]\\([ \t\n]+\\|\"\\)"
-					   (save-excursion
-					     (end-of-line)
-					     (point))
-					   t)
+					   (line-end-position) t)
 			(< (current-column) numc))
 		   (if (checkdoc-autofix-ask-replace
 			p (1+ p)
@@ -1526,9 +1521,7 @@
 	   (if msg
 	       (checkdoc-create-error msg s (save-excursion
 					      (goto-char s)
-					      (end-of-line)
-					      (point)))
-	     nil) ))))
+					      (line-end-position))))))))
      ;; Continuation of above.  Make sure our sentence is capitalized.
      (save-excursion
        (skip-chars-forward "\"\\*")
@@ -1628,7 +1621,7 @@
 	 (if (and (< (point) e) (> (current-column) 80))
 	     (checkdoc-create-error
 	      "Some lines are over 80 columns wide"
-	      s (save-excursion (goto-char s) (end-of-line) (point)) ))))
+	      s (save-excursion (goto-char s) (line-end-position))))))
      ;; Here we deviate to tests based on a variable or function.
      ;; We must do this before checking for symbols in quotes because there
      ;; is a chance that just such a symbol might really be an argument.
@@ -1773,9 +1766,8 @@
 				 (end-of-line)
 				 ;; check string-continuation
 				 (if (checkdoc-char= (preceding-char) ?\\)
-				     (progn (forward-line 1)
-					    (end-of-line)))
-				 (point)))
+				     (line-end-position 2)
+				   (point))))
 			  (rs nil) replace original (case-fold-search t))
 		      (while (and (not rs)
 				  (re-search-forward
@@ -2253,8 +2245,8 @@
 		 (insert ";;; " fn fe " --- " (read-string "Summary: ") "\n"))
 	     (checkdoc-create-error
 	      "The first line should be of the form: \";;; package --- Summary\""
-	      (point-min) (save-excursion (goto-char (point-min)) (end-of-line)
-					  (point))))
+	      (point-min) (save-excursion (goto-char (point-min))
+					  (line-end-position))))
 	 nil))
       (setq
        err
@@ -2676,5 +2668,4 @@
 
 (provide 'checkdoc)
 
-;; arch-tag: c49a7ec8-3bb7-46f2-bfbc-d5f26e033b26
 ;;; checkdoc.el ends here
--- a/lisp/emacs-lisp/cl-loaddefs.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/emacs-lisp/cl-loaddefs.el	Mon Nov 08 14:19:54 2010 +0900
@@ -282,7 +282,7 @@
 ;;;;;;  do-all-symbols do-symbols dotimes dolist do* do loop return-from
 ;;;;;;  return block etypecase typecase ecase case load-time-value
 ;;;;;;  eval-when destructuring-bind function* defmacro* defun* gentemp
-;;;;;;  gensym) "cl-macs" "cl-macs.el" "c10b5cbebb5267291ef15c782c0271a6")
+;;;;;;  gensym) "cl-macs" "cl-macs.el" "82f8370745a60dc26536a0237cba893f")
 ;;; Generated autoloads from cl-macs.el
 
 (autoload 'gensym "cl-macs" "\
--- a/lisp/emacs-lisp/cl-macs.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/emacs-lisp/cl-macs.el	Mon Nov 08 14:19:54 2010 +0900
@@ -639,7 +639,7 @@
 
 ;;; The "loop" macro.
 
-(defvar args) (defvar loop-accum-var) (defvar loop-accum-vars)
+(defvar loop-args) (defvar loop-accum-var) (defvar loop-accum-vars)
 (defvar loop-bindings) (defvar loop-body) (defvar loop-destr-temps)
 (defvar loop-finally) (defvar loop-finish-flag) (defvar loop-first-flag)
 (defvar loop-initially) (defvar loop-map-form) (defvar loop-name)
@@ -647,7 +647,7 @@
 (defvar loop-result-var) (defvar loop-steps) (defvar loop-symbol-macs)
 
 ;;;###autoload
-(defmacro loop (&rest args)
+(defmacro loop (&rest loop-args)
   "The Common Lisp `loop' macro.
 Valid clauses are:
   for VAR from/upfrom/downfrom NUM to/upto/downto/above/below NUM by NUM,
@@ -662,8 +662,8 @@
   finally return EXPR, named NAME.
 
 \(fn CLAUSE...)"
-  (if (not (memq t (mapcar 'symbolp (delq nil (delq t (copy-list args))))))
-      (list 'block nil (list* 'while t args))
+  (if (not (memq t (mapcar 'symbolp (delq nil (delq t (copy-list loop-args))))))
+      (list 'block nil (list* 'while t loop-args))
     (let ((loop-name nil)	(loop-bindings nil)
 	  (loop-body nil)	(loop-steps nil)
 	  (loop-result nil)	(loop-result-explicit nil)
@@ -672,8 +672,8 @@
 	  (loop-initially nil)	(loop-finally nil)
 	  (loop-map-form nil)   (loop-first-flag nil)
 	  (loop-destr-temps nil) (loop-symbol-macs nil))
-      (setq args (append args '(cl-end-loop)))
-      (while (not (eq (car args) 'cl-end-loop)) (cl-parse-loop-clause))
+      (setq loop-args (append loop-args '(cl-end-loop)))
+      (while (not (eq (car loop-args) 'cl-end-loop)) (cl-parse-loop-clause))
       (if loop-finish-flag
 	  (push `((,loop-finish-flag t)) loop-bindings))
       (if loop-first-flag
@@ -713,34 +713,34 @@
 	    (setq body (list (list* 'symbol-macrolet loop-symbol-macs body))))
 	(list* 'block loop-name body)))))
 
-(defun cl-parse-loop-clause ()		; uses args, loop-*
-  (let ((word (pop args))
+(defun cl-parse-loop-clause ()		; uses loop-*
+  (let ((word (pop loop-args))
 	(hash-types '(hash-key hash-keys hash-value hash-values))
 	(key-types '(key-code key-codes key-seq key-seqs
 		     key-binding key-bindings)))
     (cond
 
-     ((null args)
+     ((null loop-args)
       (error "Malformed `loop' macro"))
 
      ((eq word 'named)
-      (setq loop-name (pop args)))
+      (setq loop-name (pop loop-args)))
 
      ((eq word 'initially)
-      (if (memq (car args) '(do doing)) (pop args))
-      (or (consp (car args)) (error "Syntax error on `initially' clause"))
-      (while (consp (car args))
-	(push (pop args) loop-initially)))
+      (if (memq (car loop-args) '(do doing)) (pop loop-args))
+      (or (consp (car loop-args)) (error "Syntax error on `initially' clause"))
+      (while (consp (car loop-args))
+	(push (pop loop-args) loop-initially)))
 
      ((eq word 'finally)
-      (if (eq (car args) 'return)
-	  (setq loop-result-explicit (or (cl-pop2 args) '(quote nil)))
-	(if (memq (car args) '(do doing)) (pop args))
-	(or (consp (car args)) (error "Syntax error on `finally' clause"))
-	(if (and (eq (caar args) 'return) (null loop-name))
-	    (setq loop-result-explicit (or (nth 1 (pop args)) '(quote nil)))
-	  (while (consp (car args))
-	    (push (pop args) loop-finally)))))
+      (if (eq (car loop-args) 'return)
+	  (setq loop-result-explicit (or (cl-pop2 loop-args) '(quote nil)))
+	(if (memq (car loop-args) '(do doing)) (pop loop-args))
+	(or (consp (car loop-args)) (error "Syntax error on `finally' clause"))
+	(if (and (eq (caar loop-args) 'return) (null loop-name))
+	    (setq loop-result-explicit (or (nth 1 (pop loop-args)) '(quote nil)))
+	  (while (consp (car loop-args))
+	    (push (pop loop-args) loop-finally)))))
 
      ((memq word '(for as))
       (let ((loop-for-bindings nil) (loop-for-sets nil) (loop-for-steps nil)
@@ -749,29 +749,29 @@
 	    ;; Use `gensym' rather than `make-symbol'.  It's important that
 	    ;; (not (eq (symbol-name var1) (symbol-name var2))) because
 	    ;; these vars get added to the cl-macro-environment.
-	    (let ((var (or (pop args) (gensym "--cl-var--"))))
-	      (setq word (pop args))
-	      (if (eq word 'being) (setq word (pop args)))
-	      (if (memq word '(the each)) (setq word (pop args)))
+	    (let ((var (or (pop loop-args) (gensym "--cl-var--"))))
+	      (setq word (pop loop-args))
+	      (if (eq word 'being) (setq word (pop loop-args)))
+	      (if (memq word '(the each)) (setq word (pop loop-args)))
 	      (if (memq word '(buffer buffers))
-		  (setq word 'in args (cons '(buffer-list) args)))
+		  (setq word 'in loop-args (cons '(buffer-list) loop-args)))
 	      (cond
 
 	       ((memq word '(from downfrom upfrom to downto upto
 			     above below by))
-		(push word args)
-		(if (memq (car args) '(downto above))
+		(push word loop-args)
+		(if (memq (car loop-args) '(downto above))
 		    (error "Must specify `from' value for downward loop"))
-		(let* ((down (or (eq (car args) 'downfrom)
-				 (memq (caddr args) '(downto above))))
-		       (excl (or (memq (car args) '(above below))
-				 (memq (caddr args) '(above below))))
-		       (start (and (memq (car args) '(from upfrom downfrom))
-				   (cl-pop2 args)))
-		       (end (and (memq (car args)
+		(let* ((down (or (eq (car loop-args) 'downfrom)
+				 (memq (caddr loop-args) '(downto above))))
+		       (excl (or (memq (car loop-args) '(above below))
+				 (memq (caddr loop-args) '(above below))))
+		       (start (and (memq (car loop-args) '(from upfrom downfrom))
+				   (cl-pop2 loop-args)))
+		       (end (and (memq (car loop-args)
 				       '(to upto downto above below))
-				 (cl-pop2 args)))
-		       (step (and (eq (car args) 'by) (cl-pop2 args)))
+				 (cl-pop2 loop-args)))
+		       (step (and (eq (car loop-args) 'by) (cl-pop2 loop-args)))
 		       (end-var (and (not (cl-const-expr-p end))
 				     (make-symbol "--cl-var--")))
 		       (step-var (and (not (cl-const-expr-p step))
@@ -794,7 +794,7 @@
 		(let* ((on (eq word 'on))
 		       (temp (if (and on (symbolp var))
 				 var (make-symbol "--cl-var--"))))
-		  (push (list temp (pop args)) loop-for-bindings)
+		  (push (list temp (pop loop-args)) loop-for-bindings)
 		  (push (list 'consp temp) loop-body)
 		  (if (eq word 'in-ref)
 		      (push (list var (list 'car temp)) loop-symbol-macs)
@@ -804,8 +804,8 @@
 			  (push (list var (if on temp (list 'car temp)))
 				loop-for-sets))))
 		  (push (list temp
-			      (if (eq (car args) 'by)
-				  (let ((step (cl-pop2 args)))
+			      (if (eq (car loop-args) 'by)
+				  (let ((step (cl-pop2 loop-args)))
 				    (if (and (memq (car-safe step)
 						   '(quote function
 							   function*))
@@ -816,10 +816,10 @@
 			loop-for-steps)))
 
 	       ((eq word '=)
-		(let* ((start (pop args))
-		       (then (if (eq (car args) 'then) (cl-pop2 args) start)))
+		(let* ((start (pop loop-args))
+		       (then (if (eq (car loop-args) 'then) (cl-pop2 loop-args) start)))
 		  (push (list var nil) loop-for-bindings)
-		  (if (or ands (eq (car args) 'and))
+		  (if (or ands (eq (car loop-args) 'and))
 		      (progn
 			(push `(,var
 				(if ,(or loop-first-flag
@@ -839,7 +839,7 @@
 	       ((memq word '(across across-ref))
 		(let ((temp-vec (make-symbol "--cl-vec--"))
 		      (temp-idx (make-symbol "--cl-idx--")))
-		  (push (list temp-vec (pop args)) loop-for-bindings)
+		  (push (list temp-vec (pop loop-args)) loop-for-bindings)
 		  (push (list temp-idx -1) loop-for-bindings)
 		  (push (list '< (list 'setq temp-idx (list '1+ temp-idx))
 			      (list 'length temp-vec)) loop-body)
@@ -851,15 +851,15 @@
 			  loop-for-sets))))
 
 	       ((memq word '(element elements))
-		(let ((ref (or (memq (car args) '(in-ref of-ref))
-			       (and (not (memq (car args) '(in of)))
+		(let ((ref (or (memq (car loop-args) '(in-ref of-ref))
+			       (and (not (memq (car loop-args) '(in of)))
 				    (error "Expected `of'"))))
-		      (seq (cl-pop2 args))
+		      (seq (cl-pop2 loop-args))
 		      (temp-seq (make-symbol "--cl-seq--"))
-		      (temp-idx (if (eq (car args) 'using)
-				    (if (and (= (length (cadr args)) 2)
-					     (eq (caadr args) 'index))
-					(cadr (cl-pop2 args))
+		      (temp-idx (if (eq (car loop-args) 'using)
+				    (if (and (= (length (cadr loop-args)) 2)
+					     (eq (caadr loop-args) 'index))
+					(cadr (cl-pop2 loop-args))
 				      (error "Bad `using' clause"))
 				  (make-symbol "--cl-idx--"))))
 		  (push (list temp-seq seq) loop-for-bindings)
@@ -885,13 +885,13 @@
 			loop-for-steps)))
 
 	       ((memq word hash-types)
-		(or (memq (car args) '(in of)) (error "Expected `of'"))
-		(let* ((table (cl-pop2 args))
-		       (other (if (eq (car args) 'using)
-				  (if (and (= (length (cadr args)) 2)
-					   (memq (caadr args) hash-types)
-					   (not (eq (caadr args) word)))
-				      (cadr (cl-pop2 args))
+		(or (memq (car loop-args) '(in of)) (error "Expected `of'"))
+		(let* ((table (cl-pop2 loop-args))
+		       (other (if (eq (car loop-args) 'using)
+				  (if (and (= (length (cadr loop-args)) 2)
+					   (memq (caadr loop-args) hash-types)
+					   (not (eq (caadr loop-args) word)))
+				      (cadr (cl-pop2 loop-args))
 				    (error "Bad `using' clause"))
 				(make-symbol "--cl-var--"))))
 		  (if (memq word '(hash-value hash-values))
@@ -901,16 +901,16 @@
 
 	       ((memq word '(symbol present-symbol external-symbol
 			     symbols present-symbols external-symbols))
-		(let ((ob (and (memq (car args) '(in of)) (cl-pop2 args))))
+		(let ((ob (and (memq (car loop-args) '(in of)) (cl-pop2 loop-args))))
 		  (setq loop-map-form
 			`(mapatoms (lambda (,var) . --cl-map) ,ob))))
 
 	       ((memq word '(overlay overlays extent extents))
 		(let ((buf nil) (from nil) (to nil))
-		  (while (memq (car args) '(in of from to))
-		    (cond ((eq (car args) 'from) (setq from (cl-pop2 args)))
-			  ((eq (car args) 'to) (setq to (cl-pop2 args)))
-			  (t (setq buf (cl-pop2 args)))))
+		  (while (memq (car loop-args) '(in of from to))
+		    (cond ((eq (car loop-args) 'from) (setq from (cl-pop2 loop-args)))
+			  ((eq (car loop-args) 'to) (setq to (cl-pop2 loop-args)))
+			  (t (setq buf (cl-pop2 loop-args)))))
 		  (setq loop-map-form
 			`(cl-map-extents
 			  (lambda (,var ,(make-symbol "--cl-var--"))
@@ -921,12 +921,12 @@
 		(let ((buf nil) (prop nil) (from nil) (to nil)
 		      (var1 (make-symbol "--cl-var1--"))
 		      (var2 (make-symbol "--cl-var2--")))
-		  (while (memq (car args) '(in of property from to))
-		    (cond ((eq (car args) 'from) (setq from (cl-pop2 args)))
-			  ((eq (car args) 'to) (setq to (cl-pop2 args)))
-			  ((eq (car args) 'property)
-			   (setq prop (cl-pop2 args)))
-			  (t (setq buf (cl-pop2 args)))))
+		  (while (memq (car loop-args) '(in of property from to))
+		    (cond ((eq (car loop-args) 'from) (setq from (cl-pop2 loop-args)))
+			  ((eq (car loop-args) 'to) (setq to (cl-pop2 loop-args)))
+			  ((eq (car loop-args) 'property)
+			   (setq prop (cl-pop2 loop-args)))
+			  (t (setq buf (cl-pop2 loop-args)))))
 		  (if (and (consp var) (symbolp (car var)) (symbolp (cdr var)))
 		      (setq var1 (car var) var2 (cdr var))
 		    (push (list var (list 'cons var1 var2)) loop-for-sets))
@@ -936,13 +936,13 @@
 			  ,buf ,prop ,from ,to))))
 
 	       ((memq word key-types)
-		(or (memq (car args) '(in of)) (error "Expected `of'"))
-		(let ((map (cl-pop2 args))
-		      (other (if (eq (car args) 'using)
-				 (if (and (= (length (cadr args)) 2)
-					  (memq (caadr args) key-types)
-					  (not (eq (caadr args) word)))
-				     (cadr (cl-pop2 args))
+		(or (memq (car loop-args) '(in of)) (error "Expected `of'"))
+		(let ((map (cl-pop2 loop-args))
+		      (other (if (eq (car loop-args) 'using)
+				 (if (and (= (length (cadr loop-args)) 2)
+					  (memq (caadr loop-args) key-types)
+					  (not (eq (caadr loop-args) word)))
+				     (cadr (cl-pop2 loop-args))
 				   (error "Bad `using' clause"))
 			       (make-symbol "--cl-var--"))))
 		  (if (memq word '(key-binding key-bindings))
@@ -964,7 +964,7 @@
 			loop-for-steps)))
 
 	       ((memq word '(window windows))
-		(let ((scr (and (memq (car args) '(in of)) (cl-pop2 args)))
+		(let ((scr (and (memq (car loop-args) '(in of)) (cl-pop2 loop-args)))
 		      (temp (make-symbol "--cl-var--")))
 		  (push (list var (if scr
 				      (list 'frame-selected-window scr)
@@ -982,9 +982,9 @@
 		  (if handler
 		      (funcall handler var)
 		    (error "Expected a `for' preposition, found %s" word)))))
-	      (eq (car args) 'and))
+	      (eq (car loop-args) 'and))
 	  (setq ands t)
-	  (pop args))
+	  (pop loop-args))
 	(if (and ands loop-for-bindings)
 	    (push (nreverse loop-for-bindings) loop-bindings)
 	  (setq loop-bindings (nconc (mapcar 'list loop-for-bindings)
@@ -1000,11 +1000,11 @@
 
      ((eq word 'repeat)
       (let ((temp (make-symbol "--cl-var--")))
-	(push (list (list temp (pop args))) loop-bindings)
+	(push (list (list temp (pop loop-args))) loop-bindings)
 	(push (list '>= (list 'setq temp (list '1- temp)) 0) loop-body)))
 
      ((memq word '(collect collecting))
-      (let ((what (pop args))
+      (let ((what (pop loop-args))
 	    (var (cl-loop-handle-accum nil 'nreverse)))
 	(if (eq var loop-accum-var)
 	    (push (list 'progn (list 'push what var) t) loop-body)
@@ -1013,7 +1013,7 @@
 		      t) loop-body))))
 
      ((memq word '(nconc nconcing append appending))
-      (let ((what (pop args))
+      (let ((what (pop loop-args))
 	    (var (cl-loop-handle-accum nil 'nreverse)))
 	(push (list 'progn
 		    (list 'setq var
@@ -1028,27 +1028,27 @@
 				  var what))) t) loop-body)))
 
      ((memq word '(concat concating))
-      (let ((what (pop args))
+      (let ((what (pop loop-args))
 	    (var (cl-loop-handle-accum "")))
 	(push (list 'progn (list 'callf 'concat var what) t) loop-body)))
 
      ((memq word '(vconcat vconcating))
-      (let ((what (pop args))
+      (let ((what (pop loop-args))
 	    (var (cl-loop-handle-accum [])))
 	(push (list 'progn (list 'callf 'vconcat var what) t) loop-body)))
 
      ((memq word '(sum summing))
-      (let ((what (pop args))
+      (let ((what (pop loop-args))
 	    (var (cl-loop-handle-accum 0)))
 	(push (list 'progn (list 'incf var what) t) loop-body)))
 
      ((memq word '(count counting))
-      (let ((what (pop args))
+      (let ((what (pop loop-args))
 	    (var (cl-loop-handle-accum 0)))
 	(push (list 'progn (list 'if what (list 'incf var)) t) loop-body)))
 
      ((memq word '(minimize minimizing maximize maximizing))
-      (let* ((what (pop args))
+      (let* ((what (pop loop-args))
 	     (temp (if (cl-simple-expr-p what) what (make-symbol "--cl-var--")))
 	     (var (cl-loop-handle-accum nil))
 	     (func (intern (substring (symbol-name word) 0 3)))
@@ -1059,27 +1059,27 @@
 
      ((eq word 'with)
       (let ((bindings nil))
-	(while (progn (push (list (pop args)
-				  (and (eq (car args) '=) (cl-pop2 args)))
+	(while (progn (push (list (pop loop-args)
+				  (and (eq (car loop-args) '=) (cl-pop2 loop-args)))
 			    bindings)
-		      (eq (car args) 'and))
-	  (pop args))
+		      (eq (car loop-args) 'and))
+	  (pop loop-args))
 	(push (nreverse bindings) loop-bindings)))
 
      ((eq word 'while)
-      (push (pop args) loop-body))
+      (push (pop loop-args) loop-body))
 
      ((eq word 'until)
-      (push (list 'not (pop args)) loop-body))
+      (push (list 'not (pop loop-args)) loop-body))
 
      ((eq word 'always)
       (or loop-finish-flag (setq loop-finish-flag (make-symbol "--cl-flag--")))
-      (push (list 'setq loop-finish-flag (pop args)) loop-body)
+      (push (list 'setq loop-finish-flag (pop loop-args)) loop-body)
       (setq loop-result t))
 
      ((eq word 'never)
       (or loop-finish-flag (setq loop-finish-flag (make-symbol "--cl-flag--")))
-      (push (list 'setq loop-finish-flag (list 'not (pop args)))
+      (push (list 'setq loop-finish-flag (list 'not (pop loop-args)))
 	    loop-body)
       (setq loop-result t))
 
@@ -1087,20 +1087,20 @@
       (or loop-finish-flag (setq loop-finish-flag (make-symbol "--cl-flag--")))
       (or loop-result-var (setq loop-result-var (make-symbol "--cl-var--")))
       (push (list 'setq loop-finish-flag
-		  (list 'not (list 'setq loop-result-var (pop args))))
+		  (list 'not (list 'setq loop-result-var (pop loop-args))))
 	    loop-body))
 
      ((memq word '(if when unless))
-      (let* ((cond (pop args))
+      (let* ((cond (pop loop-args))
 	     (then (let ((loop-body nil))
 		     (cl-parse-loop-clause)
 		     (cl-loop-build-ands (nreverse loop-body))))
 	     (else (let ((loop-body nil))
-		     (if (eq (car args) 'else)
-			 (progn (pop args) (cl-parse-loop-clause)))
+		     (if (eq (car loop-args) 'else)
+			 (progn (pop loop-args) (cl-parse-loop-clause)))
 		     (cl-loop-build-ands (nreverse loop-body))))
 	     (simple (and (eq (car then) t) (eq (car else) t))))
-	(if (eq (car args) 'end) (pop args))
+	(if (eq (car loop-args) 'end) (pop loop-args))
 	(if (eq word 'unless) (setq then (prog1 else (setq else then))))
 	(let ((form (cons (if simple (cons 'progn (nth 1 then)) (nth 2 then))
 			  (if simple (nth 1 else) (list (nth 2 else))))))
@@ -1114,22 +1114,22 @@
 
      ((memq word '(do doing))
       (let ((body nil))
-	(or (consp (car args)) (error "Syntax error on `do' clause"))
-	(while (consp (car args)) (push (pop args) body))
+	(or (consp (car loop-args)) (error "Syntax error on `do' clause"))
+	(while (consp (car loop-args)) (push (pop loop-args) body))
 	(push (cons 'progn (nreverse (cons t body))) loop-body)))
 
      ((eq word 'return)
       (or loop-finish-flag (setq loop-finish-flag (make-symbol "--cl-var--")))
       (or loop-result-var (setq loop-result-var (make-symbol "--cl-var--")))
-      (push (list 'setq loop-result-var (pop args)
+      (push (list 'setq loop-result-var (pop loop-args)
 		  loop-finish-flag nil) loop-body))
 
      (t
       (let ((handler (and (symbolp word) (get word 'cl-loop-handler))))
 	(or handler (error "Expected a loop keyword, found %s" word))
 	(funcall handler))))
-    (if (eq (car args) 'and)
-	(progn (pop args) (cl-parse-loop-clause)))))
+    (if (eq (car loop-args) 'and)
+	(progn (pop loop-args) (cl-parse-loop-clause)))))
 
 (defun cl-loop-let (specs body par)   ; uses loop-*
   (let ((p specs) (temps nil) (new nil))
@@ -1165,9 +1165,9 @@
       (list* (if par 'let 'let*)
 	     (nconc (nreverse temps) (nreverse new)) body))))
 
-(defun cl-loop-handle-accum (def &optional func)   ; uses args, loop-*
-  (if (eq (car args) 'into)
-      (let ((var (cl-pop2 args)))
+(defun cl-loop-handle-accum (def &optional func)   ; uses loop-*
+  (if (eq (car loop-args) 'into)
+      (let ((var (cl-pop2 loop-args)))
 	(or (memq var loop-accum-vars)
 	    (progn (push (list (list var def)) loop-bindings)
 		   (push var loop-accum-vars)))
@@ -2791,5 +2791,4 @@
 ;; generated-autoload-file: "cl-loaddefs.el"
 ;; End:
 
-;; arch-tag: afd947a6-b553-4df1-bba5-000be6388f46
 ;;; cl-macs.el ends here
--- a/lisp/emacs-lisp/easy-mmode.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/emacs-lisp/easy-mmode.el	Mon Nov 08 14:19:54 2010 +0900
@@ -119,7 +119,8 @@
 		of the variable MODE to store the state of the mode.  PLACE
 		can also be of the form (GET . SET) where GET is an expression
 		that returns the current state and SET is a function that takes
-		a new state and sets it.
+		a new state and sets it.  If you specify a :variable, this
+		function assumes it is defined elsewhere.
 
 For example, you could write
   (define-minor-mode foo-mode \"If enabled, foo on you!\"
@@ -196,6 +197,7 @@
 	    `(:group ',(intern (replace-regexp-in-string
 				"-mode\\'" "" mode-name)))))
 
+    ;; TODO? Mark booleans as safe if booleanp?  Eg abbrev-mode.
     (unless type (setq type '(:type 'boolean)))
 
     `(progn
@@ -583,5 +585,4 @@
 
 (provide 'easy-mmode)
 
-;; arch-tag: d48a5250-6961-4528-9cb0-3c9ea042a66a
 ;;; easy-mmode.el ends here
--- a/lisp/emacs-lisp/edebug.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/emacs-lisp/edebug.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,8 +1,8 @@
 ;;; edebug.el --- a source-level debugger for Emacs Lisp
 
-;; Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1997, 1999,
-;;   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-;;   Free Software Foundation, Inc.
+;; Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1997,
+;;   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
+;;   2010  Free Software Foundation, Inc.
 
 ;; Author: Daniel LaLiberte <liberte@holonexus.org>
 ;; Maintainer: FSF
@@ -2991,7 +2991,7 @@
   ;; Set up the overlay arrow at beginning-of-line in current buffer.
   ;; The arrow string is derived from edebug-arrow-alist and
   ;; edebug-execution-mode.
-  (let ((pos (save-excursion (beginning-of-line) (point))))
+  (let ((pos (line-beginning-position)))
     (setq overlay-arrow-string
 	  (cdr (assq edebug-execution-mode edebug-arrow-alist)))
     (setq overlay-arrow-position (make-marker))
@@ -4454,5 +4454,4 @@
 
 (provide 'edebug)
 
-;; arch-tag: 19c8d05c-4554-426e-ac72-e0fa1fcb0808
 ;;; edebug.el ends here
--- a/lisp/emacs-lisp/eieio-comp.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/emacs-lisp/eieio-comp.el	Mon Nov 08 14:19:54 2010 +0900
@@ -47,10 +47,6 @@
 ;; This teaches the byte compiler how to do this sort of thing.
 (put 'defmethod 'byte-hunk-handler 'byte-compile-file-form-defmethod)
 
-;; Variables used free:
-(defvar outbuffer)
-(defvar filename)
-
 (defun byte-compile-file-form-defmethod (form)
   "Mumble about the method we are compiling.
 This function is mostly ripped from `byte-compile-file-form-defun',
@@ -83,14 +79,18 @@
 	 (class (if (listp arg1) (nth 1 arg1) nil))
 	 (my-outbuffer (if (eval-when-compile (featurep 'xemacs))
 			   byte-compile-outbuffer
-			 (condition-case nil
-			     bytecomp-outbuffer
-			   (error outbuffer))))
-	 )
+			 (cond ((boundp 'bytecomp-outbuffer)
+				bytecomp-outbuffer) ; Emacs >= 23.2
+			       ((boundp 'outbuffer) outbuffer)
+			       (t (error "Unable to set outbuffer"))))))
     (let ((name (format "%s::%s" (or class "#<generic>") meth)))
       (if byte-compile-verbose
 	  ;; #### filename used free
-	  (message "Compiling %s... (%s)" (or filename "") name))
+	  (message "Compiling %s... (%s)"
+		   (cond ((boundp 'bytecomp-filename) bytecomp-filename)
+			 ((boundp 'filename) filename)
+			 (t ""))
+		   name))
       (setq byte-compile-current-form name) ; for warnings
       )
     ;; Flush any pending output
@@ -139,5 +139,4 @@
 
 (provide 'eieio-comp)
 
-;; arch-tag: f2aacdd3-1da2-4ee9-b3e5-e8eac0832ee3
 ;;; eieio-comp.el ends here
--- a/lisp/emacs-lisp/elint.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/emacs-lisp/elint.el	Mon Nov 08 14:19:54 2010 +0900
@@ -394,40 +394,41 @@
   (parse-partial-sexp (point) (point-max) nil t)
   (not (eobp)))
 
-(defvar env)				; from elint-init-env
+(defvar elint-env)			; from elint-init-env
 
 (defun elint-init-form (form)
-  "Process FORM, adding to ENV if recognized."
+  "Process FORM, adding to ELINT-ENV if recognized."
   (cond
    ;; Eg nnmaildir seems to use [] as a form of comment syntax.
    ((not (listp form))
     (elint-warning "Skipping non-list form `%s'" form))
    ;; Add defined variable
    ((memq (car form) '(defvar defconst defcustom))
-    (setq env (elint-env-add-var env (cadr form))))
+    (setq elint-env (elint-env-add-var elint-env (cadr form))))
    ;; Add function
    ((memq (car form) '(defun defsubst))
-    (setq env (elint-env-add-func env (cadr form) (nth 2 form))))
+    (setq elint-env (elint-env-add-func elint-env (cadr form) (nth 2 form))))
    ;; FIXME needs a handler to say second arg is not a variable when we come
    ;; to scan the form.
    ((eq (car form) 'define-derived-mode)
-    (setq env (elint-env-add-func env (cadr form) ())
-	  env (elint-env-add-var env (cadr form))
-	  env (elint-env-add-var env (intern (format "%s-map" (cadr form))))))
+    (setq elint-env (elint-env-add-func elint-env (cadr form) ())
+	  elint-env (elint-env-add-var elint-env (cadr form))
+	  elint-env (elint-env-add-var elint-env
+				       (intern (format "%s-map" (cadr form))))))
    ((eq (car form) 'define-minor-mode)
-    (setq env (elint-env-add-func env (cadr form) '(&optional arg))
+    (setq elint-env (elint-env-add-func elint-env (cadr form) '(&optional arg))
 	  ;; FIXME mode map?
-	  env (elint-env-add-var env (cadr form))))
+	  elint-env (elint-env-add-var elint-env (cadr form))))
    ((and (eq (car form) 'easy-menu-define)
 	 (cadr form))
-    (setq env (elint-env-add-func env (cadr form) '(event))
-	  env (elint-env-add-var env (cadr form))))
+    (setq elint-env (elint-env-add-func elint-env (cadr form) '(event))
+	  elint-env (elint-env-add-var elint-env (cadr form))))
    ;; FIXME it would be nice to check the autoloads are correct.
    ((eq (car form) 'autoload)
-    (setq env (elint-env-add-func env (cadr (cadr form)) 'unknown)))
+    (setq elint-env (elint-env-add-func elint-env (cadr (cadr form)) 'unknown)))
    ((eq (car form) 'declare-function)
-    (setq env (elint-env-add-func
-	       env (cadr form)
+    (setq elint-env (elint-env-add-func
+	       elint-env (cadr form)
 	       (if (or (< (length form) 4)
 		       (eq (nth 3 form) t)
 		       (unless (stringp (nth 2 form))
@@ -440,14 +441,14 @@
     ;; If the alias points to something already in the environment,
     ;; add the alias to the environment with the same arguments.
     ;; FIXME symbol-function, eg backquote.el?
-    (let ((def (elint-env-find-func env (cadr (nth 2 form)))))
-      (setq env (elint-env-add-func env (cadr (cadr form))
+    (let ((def (elint-env-find-func elint-env (cadr (nth 2 form)))))
+      (setq elint-env (elint-env-add-func elint-env (cadr (cadr form))
 				    (if def (cadr def) 'unknown)))))
    ;; Add macro, both as a macro and as a function
    ((eq (car form) 'defmacro)
-    (setq env (elint-env-add-macro env (cadr form)
+    (setq elint-env (elint-env-add-macro elint-env (cadr form)
 				   (cons 'lambda (cddr form)))
-	  env (elint-env-add-func env (cadr form) (nth 2 form))))
+	  elint-env (elint-env-add-func elint-env (cadr form) (nth 2 form))))
    ((and (eq (car form) 'put)
 	 (= 4 (length form))
 	 (eq (car-safe (cadr form)) 'quote)
@@ -471,12 +472,12 @@
 	     (setq name 'cl-macs
 		   file nil
 		   elint-doing-cl t)) ; blech
-	(setq env (elint-add-required-env env name file))))))
-  env)
+	(setq elint-env (elint-add-required-env elint-env name file))))))
+  elint-env)
 
 (defun elint-init-env (forms)
   "Initialize the environment from FORMS."
-  (let ((env (elint-make-env))
+  (let ((elint-env (elint-make-env))
 	form)
     (while forms
       (setq form (elint-top-form-form (car forms))
@@ -489,7 +490,7 @@
 				   with-no-warnings))
 	  (mapc 'elint-init-form (cdr form))
 	(elint-init-form form)))
-    env))
+    elint-env))
 
 (defun elint-add-required-env (env name file)
   "Augment ENV with the variables defined by feature NAME in FILE."
@@ -1171,5 +1172,4 @@
 
 (provide 'elint)
 
-;; arch-tag: b2f061e2-af84-4ddc-8e39-f5e969ac228f
 ;;; elint.el ends here
--- a/lisp/emacs-lisp/find-func.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/emacs-lisp/find-func.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/emacs-lisp/float-sup.el	Mon Nov 08 14:19:54 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/lisp-mode.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/emacs-lisp/lisp-mode.el	Mon Nov 08 14:19:54 2010 +0900
@@ -407,10 +407,7 @@
   (if (and (buffer-modified-p)
 	   (y-or-n-p (format "Save buffer %s first? " (buffer-name))))
       (save-buffer))
-  (let ((compiled-file-name (byte-compile-dest-file buffer-file-name)))
-    (if (file-newer-than-file-p compiled-file-name buffer-file-name)
-	(load-file compiled-file-name)
-      (byte-compile-file buffer-file-name t))))
+  (byte-recompile-file buffer-file-name nil 0 t))
 
 (defcustom emacs-lisp-mode-hook nil
   "Hook run when entering Emacs Lisp mode."
@@ -1070,7 +1067,7 @@
                        (goto-char calculate-lisp-indent-last-sexp)
                        (or (and (looking-at ":")
                                 (setq indent (current-column)))
-                           (and (< (save-excursion (beginning-of-line) (point))
+                           (and (< (line-beginning-position)
                                    (prog2 (backward-sexp) (point)))
                                 (looking-at ":")
                                 (setq indent (current-column))))
@@ -1432,5 +1429,4 @@
 
 (provide 'lisp-mode)
 
-;; arch-tag: 414c7f93-c245-4b77-8ed5-ed05ef7ff1bf
 ;;; lisp-mode.el ends here
--- a/lisp/emacs-lisp/package.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/emacs-lisp/package.el	Mon Nov 08 14:19:54 2010 +0900
@@ -77,7 +77,7 @@
 
 ;; Other external functions you may want to use:
 ;;
-;; M-x package-list-packages
+;; M-x list-packages
 ;;    Enters a mode similar to buffer-menu which lets you manage
 ;;    packages.  You can choose packages for install (mark with "i",
 ;;    then "x" to execute) or deletion (not implemented yet), and you
@@ -215,7 +215,6 @@
 (declare-function url-http-parse-response "url-http" ())
 (declare-function lm-header "lisp-mnt" (header))
 (declare-function lm-commentary "lisp-mnt" (&optional file))
-(declare-function dired-delete-file "dired" (file &optional recursive trash))
 (defvar url-http-end-of-headers)
 
 (defcustom package-archives '(("gnu" . "http://elpa.gnu.org/packages/"))
@@ -278,9 +277,12 @@
 ;; until it's needed (i.e. when `package-intialize' is called).
 (defvar package--builtins nil
   "Alist of built-in packages.
+The actual value is initialized by loading the library
+`finder-inf'; this is not done until it is needed, e.g. by the
+function `package-built-in-p'.
+
 Each element has the form (PKG . DESC), where PKG is a package
 name (a symbol) and DESC is a vector that describes the package.
-
 The vector DESC has the form [VERSION REQS DOCSTRING].
   VERSION is a version list.
   REQS is a list of packages (symbols) required by the package.
@@ -329,7 +331,9 @@
       (match-string 1 dirname)))
 
 (defun package-load-descriptor (dir package)
-  "Load the description file in directory DIR for package PACKAGE."
+  "Load the description file in directory DIR for package PACKAGE.
+Here, PACKAGE is a string of the form NAME-VER, where NAME is the
+package name and VER is its version."
   (let* ((pkg-dir (expand-file-name package dir))
 	 (pkg-file (expand-file-name
 		    (concat (package-strip-version package) "-pkg")
@@ -387,8 +391,10 @@
   "Extract the kind of download from an archive package description vector."
   (aref desc 3))
 
-(defun package--dir (name version-string)
-  (let* ((subdir (concat name "-" version-string))
+(defun package--dir (name version)
+  "Return the directory where a package is installed, or nil if none.
+NAME and VERSION are both strings."
+  (let* ((subdir (concat name "-" version))
 	 (dir-list (cons package-user-dir package-directory-list))
 	 pkg-dir)
     (while dir-list
@@ -404,7 +410,7 @@
 	 (version-str (package-version-join (package-desc-vers pkg-vec)))
 	 (pkg-dir (package--dir name version-str)))
     (unless pkg-dir
-      (error "Internal error: could not find directory for %s-%s"
+      (error "Internal error: unable to find directory for `%s-%s'"
 	     name version-str))
     ;; Add info node.
     (when (file-exists-p (expand-file-name "dir" pkg-dir))
@@ -419,42 +425,46 @@
     ;; Don't return nil.
     t))
 
-(defun package--built-in (package version)
-  "Return true if the package is built-in to Emacs."
+(defun package-built-in-p (package &optional version)
+  "Return true if PACKAGE, of VERSION or newer, is built-in to Emacs."
+  (require 'finder-inf nil t) ; For `package--builtins'.
   (let ((elt (assq package package--builtins)))
-    (and elt (version-list-= (package-desc-vers (cdr elt)) version))))
+    (and elt (version-list-<= version (package-desc-vers (cdr elt))))))
 
-;; FIXME: return a reason instead?
+;; This function goes ahead and activates a newer version of a package
+;; if an older one was already activated.  This is not ideal; we'd at
+;; least need to check to see if the package has actually been loaded,
+;; and not merely activated.
 (defun package-activate (package version)
-  "Activate a package, and recursively activate its dependencies.
+  "Activate package PACKAGE, of version VERSION or newer.
+If PACKAGE has any dependencies, recursively activate them.
 Return nil if the package could not be activated."
-  ;; Assume the user knows what he is doing -- go ahead and activate a
-  ;; newer version of a package if an older one has already been
-  ;; activated.  This is not ideal; we'd at least need to check to see
-  ;; if the package has actually been loaded, and not merely
-  ;; activated.  However, don't try to activate 'emacs', as that makes
-  ;; no sense.
-  (unless (eq package 'emacs)
-    (let* ((pkg-desc (assq package package-alist))
-	   (this-version (package-desc-vers (cdr pkg-desc)))
-	   (req-list (package-desc-reqs (cdr pkg-desc)))
-	   ;; If the package was never activated, do it now.
-	   (keep-going (or (not (memq package package-activated-list))
-			   (version-list-< version this-version))))
-      (while (and req-list keep-going)
-	(let* ((req (car req-list))
-	       (req-name (car req))
-	       (req-version (cadr req)))
-	  (or (package-activate req-name req-version)
-	      (setq keep-going nil)))
-	(setq req-list (cdr req-list)))
-      (if keep-going
-	  (package-activate-1 package (cdr pkg-desc))
-	;; We get here if a dependency failed to activate -- but we
-	;; can also get here if the requested package was already
-	;; activated.  Return non-nil in the latter case.
-	(and (memq package package-activated-list)
-	     (version-list-<= version this-version))))))
+  (let ((pkg-vec (cdr (assq package package-alist)))
+	available-version found)
+    ;; Check if PACKAGE is available in `package-alist'.
+    (when pkg-vec
+      (setq available-version (package-desc-vers pkg-vec)
+	    found (version-list-<= version available-version)))
+    (cond
+     ;; If no such package is found, maybe it's built-in.
+     ((null found)
+      (package-built-in-p package version))
+     ;; If the package is already activated, just return t.
+     ((memq package package-activated-list)
+      t)
+     ;; Otherwise, proceed with activation.
+     (t
+      (let ((fail (catch 'dep-failure
+		    ;; Activate its dependencies recursively.
+		    (dolist (req (package-desc-reqs pkg-vec))
+		      (unless (package-activate (car req) (cadr req))
+			(throw 'dep-failure req))))))
+	(if fail
+	    (warn "Unable to activate package `%s'.
+Required package `%s-%s' is unavailable"
+		  package (car fail) (package-version-join (cadr fail)))
+	  ;; If all goes well, activate the package itself.
+	  (package-activate-1 package pkg-vec)))))))
 
 (defun package-mark-obsolete (package pkg-vec)
   "Put package on the obsolete list, if not already there."
@@ -470,48 +480,45 @@
 				      pkg-vec)))
 	    package-obsolete-alist))))
 
-(defun define-package (name-str version-string
+(defun define-package (name-string version-string
 				&optional docstring requirements
 				&rest extra-properties)
   "Define a new package.
-NAME is the name of the package, a string.
-VERSION-STRING is the version of the package, a dotted sequence
-of integers.
-DOCSTRING is the optional description.
-REQUIREMENTS is a list of requirements on other packages.
+NAME-STRING is the name of the package, as a string.
+VERSION-STRING is the version of the package, as a list of
+integers of the form produced by `version-to-list'.
+DOCSTRING is a short description of the package, a string.
+REQUIREMENTS is a list of dependencies on other packages.
 Each requirement is of the form (OTHER-PACKAGE \"VERSION\").
 
 EXTRA-PROPERTIES is currently unused."
-  (let* ((name (intern name-str))
-	 (pkg-desc (assq name package-alist))
-	 (new-version (version-to-list version-string))
+  (let* ((name (intern name-string))
+	 (version (version-to-list version-string))
 	 (new-pkg-desc
 	  (cons name
-		(vector new-version
+		(vector version
 			(mapcar
 			 (lambda (elt)
 			   (list (car elt)
 				 (version-to-list (car (cdr elt)))))
 			 requirements)
-			docstring))))
-    ;; Only redefine a package if the redefinition is newer.
-    (if (or (not pkg-desc)
-	    (version-list-< (package-desc-vers (cdr pkg-desc))
-			    new-version))
-	(progn
-	  (when pkg-desc
-	    ;; Remove old package and declare it obsolete.
-	    (setq package-alist (delq pkg-desc package-alist))
-	    (package-mark-obsolete (car pkg-desc) (cdr pkg-desc)))
-	  ;; Add package to the alist.
-	  (push new-pkg-desc package-alist))
-      ;; You can have two packages with the same version, for instance
-      ;; one in the system package directory and one in your private
-      ;; directory.  We just let the first one win.
-      (unless (version-list-= new-version
-			      (package-desc-vers (cdr pkg-desc)))
-	;; The package is born obsolete.
-	(package-mark-obsolete (car new-pkg-desc) (cdr new-pkg-desc))))))
+			docstring)))
+	 (old-pkg (assq name package-alist)))
+    (cond
+     ;; If there's no old package, just add this to `package-alist'.
+     ((null old-pkg)
+      (push new-pkg-desc package-alist))
+     ((version-list-< (package-desc-vers (cdr old-pkg)) version)
+      ;; Remove the old package and declare it obsolete.
+      (package-mark-obsolete name (cdr old-pkg))
+      (setq package-alist (cons new-pkg-desc
+				(delq old-pkg package-alist))))
+     ;; You can have two packages with the same version, e.g. one in
+     ;; the system package directory and one in your private
+     ;; directory.  We just let the first one win.
+     ((not (version-list-= (package-desc-vers (cdr old-pkg)) version))
+      ;; The package is born obsolete.
+      (package-mark-obsolete name (cdr new-pkg-desc))))))
 
 ;; From Emacs 22.
 (defun package-autoload-ensure-default-file (file)
@@ -562,12 +569,8 @@
 (defun package-unpack (name version)
   (let ((pkg-dir (expand-file-name (concat (symbol-name name) "-" version)
 				   package-user-dir)))
-    ;; Be careful!!
     (make-directory package-user-dir t)
-    (if (file-directory-p pkg-dir)
-	(mapc (lambda (file) nil) ; 'delete-file -- FIXME: when we're
-				  ; more confident
-	      (directory-files pkg-dir t "^[^.]")))
+    ;; FIXME: should we delete PKG-DIR if it exists?
     (let* ((default-directory (file-name-as-directory package-user-dir)))
       (package-untar-buffer)
       (package-generate-autoloads (symbol-name name) pkg-dir)
@@ -605,7 +608,7 @@
 		       (mapcar
 			(lambda (elt)
 			  (list (car elt)
-				(package-version-join (car (cdr elt)))))
+				(package-version-join (cadr elt))))
 			requires))))
 	  "\n")
 	 nil
@@ -657,10 +660,14 @@
       (kill-buffer tar-buffer))))
 
 (defun package-installed-p (package &optional min-version)
+  "Return true if PACKAGE, of VERSION or newer, is installed.
+Built-in packages also qualify."
   (let ((pkg-desc (assq package package-alist)))
-    (and pkg-desc
-	 (version-list-<= min-version
-			  (package-desc-vers (cdr pkg-desc))))))
+    (if pkg-desc
+	(version-list-<= min-version
+			 (package-desc-vers (cdr pkg-desc)))
+      ;; Also check built-in packages.
+      (package-built-in-p package min-version))))
 
 (defun package-compute-transaction (package-list requirements)
   "Return a list of packages to be installed, including PACKAGE-LIST.
@@ -691,17 +698,18 @@
 		  ((null (stringp hold))
 		   (error "Invalid element in `package-load-list'"))
 		  ((version-list-< (version-to-list hold) next-version)
-		   (error "Package '%s' held at version %s, \
+		   (error "Package `%s' held at version %s, \
 but version %s required"
 			  (symbol-name next-pkg) hold
 			  (package-version-join next-version)))))
 	  (unless pkg-desc
-	    (error "Package '%s' is not available for installation"
-		   (symbol-name next-pkg)))
+	    (error "Package `%s-%s' is unavailable"
+		   (symbol-name next-pkg)
+		   (package-version-join next-version)))
 	  (unless (version-list-<= next-version
 				   (package-desc-vers (cdr pkg-desc)))
 	    (error
-	     "Need package '%s' with version %s, but only %s is available"
+	     "Need package `%s-%s', but only %s is available"
 	     (symbol-name next-pkg) (package-version-join next-version)
 	     (package-version-join (package-desc-vers (cdr pkg-desc)))))
 	  ;; Only add to the transaction if we don't already have it.
@@ -811,7 +819,7 @@
 				  nil t))))
   (let ((pkg-desc (assq name package-archive-contents)))
     (unless pkg-desc
-      (error "Package '%s' is not available for installation"
+      (error "Package `%s' is not available for installation"
 	     (symbol-name name)))
     (package-download-transaction
      (package-compute-transaction (list name)
@@ -968,11 +976,16 @@
      (t (error "Unrecognized extension `%s'" (file-name-extension file))))))
 
 (defun package-delete (name version)
-  (require 'dired)			; for dired-delete-file
-  (dired-delete-file (expand-file-name (concat name "-" version)
-				       package-user-dir)
-		     ;; FIXME: query user?
-		     'always))
+  (let ((dir (package--dir name version)))
+    (if (string-equal (file-name-directory dir)
+		      (file-name-as-directory
+		       (expand-file-name package-user-dir)))
+	(progn
+	  (delete-directory dir t t)
+	  (message "Package `%s-%s' deleted." name version))
+      ;; Don't delete "system" packages
+      (error "Package `%s-%s' is a system package, not deleting"
+	     name version))))
 
 (defun package-archive-url (name)
   "Return the archive containing the package NAME."
@@ -1014,21 +1027,22 @@
 		      (car archive)))))
   (package-read-all-archive-contents))
 
+(defvar package--initialized nil)
+
 ;;;###autoload
-(defun package-initialize ()
+(defun package-initialize (&optional no-activate)
   "Load Emacs Lisp packages, and activate them.
-The variable `package-load-list' controls which packages to load."
+The variable `package-load-list' controls which packages to load.
+If optional arg NO-ACTIVATE is non-nil, don't activate packages."
   (interactive)
-  (require 'finder-inf nil t)
-  (setq package-alist package--builtins)
-  (setq package-activated-list (mapcar #'car package-alist))
-  (setq package-obsolete-alist nil)
+  (setq package-alist nil
+	package-obsolete-alist nil)
   (package-load-all-descriptors)
   (package-read-all-archive-contents)
-  ;; Try to activate all our packages.
-  (mapc (lambda (elt)
-	  (package-activate (car elt) (package-desc-vers (cdr elt))))
-	package-alist))
+  (unless no-activate
+    (dolist (elt package-alist)
+      (package-activate (car elt) (package-desc-vers (cdr elt)))))
+  (setq package--initialized t))
 
 
 ;;;; Package description buffer.
@@ -1037,10 +1051,15 @@
 (defun describe-package (package)
   "Display the full documentation of PACKAGE (a symbol)."
   (interactive
-   (let* ((packages (append (mapcar 'car package-alist)
-			    (mapcar 'car package-archive-contents)))
-	  (guess (function-called-at-point))
-	  val)
+   (let* ((guess (function-called-at-point))
+	  packages val)
+     (require 'finder-inf nil t)
+     ;; Load the package list if necessary (but don't activate them).
+     (unless package--initialized
+       (package-initialize t))
+     (setq packages (append (mapcar 'car package-alist)
+			    (mapcar 'car package-archive-contents)
+			    (mapcar 'car package--builtins)))
      (unless (memq guess packages)
        (setq guess nil))
      (setq packages (mapcar 'symbol-name packages))
@@ -1051,8 +1070,8 @@
 			      "Describe package: ")
 			    packages nil t nil nil guess))
      (list (if (equal val "") guess (intern val)))))
-  (if (or (null package) (null (symbolp package)))
-      (message "You did not specify a package")
+  (if (or (null package) (not (symbolp package)))
+      (message "No package specified")
     (help-setup-xref (list #'describe-package package)
 		     (called-interactively-p 'interactive))
     (with-help-window (help-buffer)
@@ -1066,22 +1085,27 @@
 	desc pkg-dir reqs version installable)
     (prin1 package)
     (princ " is ")
-    (if (setq desc (cdr (assq package package-alist)))
-	;; This package is loaded (i.e. in `package-alist').
-	(progn
-	  (setq version (package-version-join (package-desc-vers desc)))
-	  (cond (built-in
-		 (princ "a built-in package.\n\n"))
-		((setq pkg-dir (package--dir package-name version))
-		 (insert "an installed package.\n\n"))
-		(t ;; This normally does not happen.
-		 (insert "a deleted package.\n\n")
-		 (setq version nil))))
-      ;; This package is not installed.
-      (setq desc    (cdr (assq package package-archive-contents))
-	    version (package-version-join (package-desc-vers desc))
+    (cond
+     ;; Loaded packages are in `package-alist'.
+     ((setq desc (cdr (assq package package-alist)))
+      (setq version (package-version-join (package-desc-vers desc)))
+      (if (setq pkg-dir (package--dir package-name version))
+	  (insert "an installed package.\n\n")
+	;; This normally does not happen.
+	(insert "a deleted package.\n\n")))
+     ;; Available packages are in `package-archive-contents'.
+     ((setq desc (cdr (assq package package-archive-contents)))
+      (setq version (package-version-join (package-desc-vers desc))
 	    installable t)
-      (insert "an uninstalled package.\n\n"))
+      (if built-in
+	  (insert "a built-in package.\n\n")
+	(insert "an uninstalled package.\n\n")))
+     (built-in
+      (setq desc (cdr built-in)
+	    version (package-version-join (package-desc-vers desc)))
+      (insert "a built-in package.\n\n"))
+     (t
+      (insert "an orphan package.\n\n")))
 
     (insert "     " (propertize "Status" 'font-lock-face 'bold) ": ")
     (cond (pkg-dir
@@ -1091,32 +1115,35 @@
 	   ;; Todo: Add button for uninstalling.
 	   (help-insert-xref-button (file-name-as-directory pkg-dir)
 				    'help-package-def pkg-dir)
-	   (insert "'."))
+	   (if built-in
+	       (insert "',\n             shadowing a "
+		       (propertize "built-in package"
+				   'font-lock-face 'font-lock-builtin-face)
+		       ".")
+	     (insert "'.")))
 	  (installable
-	   (insert "Available -- ")
-	   (let ((button-text (if (display-graphic-p)
-				  "Install"
-				"[Install]"))
+	   (if built-in
+	       (insert (propertize "Built-in." 'font-lock-face 'font-lock-builtin-face)
+		       "  Alternate version available -- ")
+	     (insert "Available -- "))
+	   (let ((button-text (if (display-graphic-p) "Install" "[Install]"))
 		 (button-face (if (display-graphic-p)
 				  '(:box (:line-width 2 :color "dark grey")
 					 :background "light grey"
 					 :foreground "black")
 				'link)))
-	     (insert-text-button button-text
-				 'face button-face
-				 'follow-link t
+	     (insert-text-button button-text 'face button-face 'follow-link t
 				 'package-symbol package
 				 'action 'package-install-button-action)))
 	  (built-in
-	   (insert (propertize "Built-in"
-			       'font-lock-face 'font-lock-builtin-face) "."))
+	   (insert (propertize "Built-in." 'font-lock-face 'font-lock-builtin-face)))
 	  (t (insert "Deleted.")))
     (insert "\n")
-    (and version
-	 (> (length version) 0)
+    (and version (> (length version) 0)
 	 (insert "    "
 		 (propertize "Version" 'font-lock-face 'bold) ": " version "\n"))
-    (setq reqs (package-desc-reqs desc))
+
+    (setq reqs (if desc (package-desc-reqs desc)))
     (when reqs
       (insert "   " (propertize "Requires" 'font-lock-face 'bold) ": ")
       (let ((first t)
@@ -1134,9 +1161,9 @@
 	  (help-insert-xref-button text 'help-package name))
 	(insert "\n")))
     (insert "    " (propertize "Summary" 'font-lock-face 'bold)
-	    ": " (package-desc-doc desc) "\n\n")
+	    ": " (if desc (package-desc-doc desc)) "\n\n")
 
-    (if (assq package package--builtins)
+    (if built-in
 	;; For built-in packages, insert the commentary.
 	(let ((fn (locate-file (concat package-name ".el") load-path
 			       load-file-rep-suffixes))
@@ -1187,7 +1214,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)
@@ -1340,12 +1367,16 @@
 (defun package-menu-mark-delete (num)
   "Mark a package for deletion and move to the next line."
   (interactive "p")
-  (package-menu-mark-internal "D"))
+  (if (string-equal (package-menu-get-status) "installed")
+      (package-menu-mark-internal "D")
+    (forward-line)))
 
 (defun package-menu-mark-install (num)
   "Mark a package for installation and move to the next line."
   (interactive "p")
-  (package-menu-mark-internal "I"))
+  (if (string-equal (package-menu-get-status) "available")
+      (package-menu-mark-internal "I")
+    (forward-line)))
 
 (defun package-menu-mark-unmark (num)
   "Clear any marks on a package and move to the next line."
@@ -1399,34 +1430,58 @@
       "")))
 
 (defun package-menu-execute ()
-  "Perform all the marked actions.
-Packages marked for installation will be downloaded and
-installed.  Packages marked for deletion will be removed.
-Note that after installing packages you will want to restart
-Emacs."
+  "Perform marked Package Menu actions.
+Packages marked for installation are downloaded and installed;
+packages marked for deletion are removed."
   (interactive)
-  (goto-char (point-min))
-  (while (not (eobp))
-    (let ((cmd (char-after))
-	  (pkg-name (package-menu-get-package))
-	  (pkg-vers (package-menu-get-version))
-	  (pkg-status (package-menu-get-status)))
-      (cond
-       ((eq cmd ?D)
-	(when (and (string= pkg-status "installed")
-		   (string= pkg-name "package"))
-	  ;; FIXME: actually, we could be tricky and remove all info.
-	  ;; But that is drastic and the user can do that instead.
-	  (error "Can't delete most recent version of `package'"))
-	;; Ask for confirmation here?  Maybe if package status is ""?
-	;; Or if any lisp from package is actually loaded?
-	(message "Deleting %s-%s..." pkg-name pkg-vers)
-	(package-delete pkg-name pkg-vers)
-	(message "Deleting %s-%s... done" pkg-name pkg-vers))
-       ((eq cmd ?I)
-	(package-install (intern pkg-name)))))
-    (forward-line))
-  (package-menu-revert))
+  (let (install-list delete-list cmd)
+    (save-excursion
+      (goto-char (point-min))
+      (while (not (eobp))
+	(setq cmd (char-after))
+	(cond
+	 ((eq cmd ?\s) t)
+	 ((eq cmd ?D)
+	  (push (cons (package-menu-get-package)
+		      (package-menu-get-version))
+		delete-list))
+	 ((eq cmd ?I)
+	  (push (package-menu-get-package) install-list)))
+	(forward-line)))
+    ;; Delete packages, prompting if necessary.
+    (when delete-list
+      (if (yes-or-no-p
+	   (if (= (length delete-list) 1)
+	       (format "Delete package `%s-%s'? "
+		       (caar delete-list)
+		       (cdr (car delete-list)))
+	     (format "Delete these %d packages (%s)? "
+		     (length delete-list)
+		     (mapconcat (lambda (elt)
+				  (concat (car elt) "-" (cdr elt)))
+				delete-list
+				", "))))
+	  (dolist (elt delete-list)
+	    (condition-case err
+		(package-delete (car elt) (cdr elt))
+	      (error (message (cadr err)))))
+	(error "Aborted")))
+    (when install-list
+      (if (yes-or-no-p
+	   (if (= (length install-list) 1)
+	       (format "Install package `%s'? " (car install-list))
+	     (format "Install these %d packages (%s)? "
+		     (length install-list)
+		     (mapconcat 'identity install-list ", "))))
+	  (dolist (elt install-list)
+	    (package-install (intern elt)))))
+    ;; If we deleted anything, regenerate `package-alist'.  This is done
+    ;; automatically if we installed a package.
+    (and delete-list (null install-list)
+	 (package-initialize))
+    (if (or delete-list install-list)
+	(package-menu-revert)
+      (message "No operations specified."))))
 
 (defun package-print-package (package version key desc)
   (let ((face
@@ -1471,32 +1526,36 @@
 
 (defun package--generate-package-list ()
   "Populate the current Package Menu buffer."
-  (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)
       (setq name (car elt))
-      (when (and (not (eq name 'emacs)) ; Hide the `emacs' package.
-		 (or (null package-menu-package-list)
-		     (memq name package-menu-package-list)))
+      (when (or (null package-menu-package-list)
+		(memq name package-menu-package-list))
 	(setq desc (cdr elt)
-	      hold (cadr (assq name package-load-list))
-	      builtin (cdr (assq name package--builtins)))
+	      hold (cadr (assq name package-load-list)))
 	(setq info-list
 	      (package-list-maybe-add
 	       name (package-desc-vers desc)
 	       ;; FIXME: it turns out to be tricky to see if this
 	       ;; package is presently activated.
-	       (cond ((stringp hold) "held")
-		     ((and builtin
-			   (version-list-=
-			    (package-desc-vers builtin)
-			    (package-desc-vers desc)))
-		      "built-in")
-		     (t "installed"))
+	       (if (stringp hold) "held" "installed")
+	       (package-desc-doc desc)
+	       info-list))))
+
+    ;; List built-in packages
+    (dolist (elt package--builtins)
+      (setq name (car elt))
+      (when (and (not (eq name 'emacs)) ; Hide the `emacs' package.
+		 (or (null package-menu-package-list)
+		     (memq name package-menu-package-list)))
+	(setq desc (cdr elt))
+	(setq info-list
+	      (package-list-maybe-add
+	       name (package-desc-vers desc)
+	       "built-in"
 	       (package-desc-doc desc)
 	       info-list))))
 
@@ -1602,6 +1661,7 @@
   "Generate and pop to the *Packages* buffer.
 Optional PACKAGES is a list of names of packages (symbols) to
 list; the default is to display everything in `package-alist'."
+  (require 'finder-inf nil t)
   (with-current-buffer (get-buffer-create "*Packages*")
     (package-menu-mode)
     (set (make-local-variable 'package-menu-package-list) packages)
@@ -1618,6 +1678,9 @@
 Fetches the updated list of packages before displaying.
 The list is displayed in a buffer named `*Packages*'."
   (interactive)
+  ;; Initialize the package system if necessary.
+  (unless package--initialized
+    (package-initialize t))
   (package-refresh-contents)
   (package--list-packages))
 
--- a/lisp/emacs-lisp/pcase.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/emacs-lisp/pcase.el	Mon Nov 08 14:19:54 2010 +0900
@@ -25,6 +25,16 @@
 ;; ML-style pattern matching.
 ;; The entry points are autoloaded.
 
+;; Todo:
+
+;; - provide ways to extend the set of primitives, with some kind of
+;;   define-pcase-matcher.  We could easily make it so that (guard BOOLEXP)
+;;   could be defined this way, as a shorthand for (pred (lambda (_) BOOLEXP)).
+;;   But better would be if we could define new ways to match by having the
+;;   extension provide its own `pcase-split-<foo>' thingy.
+;; - ideally we'd want (pcase s ((re RE1) E1) ((re RE2) E2)) to be able to
+;;   generate a lex-style DFA to decide whether to run E1 or E2.
+
 ;;; Code:
 
 (eval-when-compile (require 'cl))
@@ -48,10 +58,12 @@
   (and UPAT...)	matches if all the patterns match.
   `QPAT		matches if the QPattern QPAT matches.
   (pred PRED)	matches if PRED applied to the object returns non-nil.
+  (guard BOOLEXP)	matches if BOOLEXP evaluates to non-nil.
 
 QPatterns can take the following forms:
   (QPAT1 . QPAT2)	matches if QPAT1 matches the car and QPAT2 the cdr.
   ,UPAT			matches if the UPattern UPAT matches.
+  STRING			matches if the object is `equal' to STRING.
   ATOM			matches if the object is `eq' to ATOM.
 QPatterns for vectors are not implemented yet.
 
@@ -77,6 +89,8 @@
   (if (null bindings) body
     `(pcase ,(cadr (car bindings))
        (,(caar bindings) (pcase-let* ,(cdr bindings) ,body))
+       ;; FIXME: In many cases `dontcare' would be preferable, so maybe we
+       ;; should have `let' and `elet', like we have `case' and `ecase'.
        (t (error "Pattern match failure in `pcase-let'")))))
 
 ;;;###autoload
@@ -167,12 +181,19 @@
   (cond
    ((eq else :pcase-dontcare) then)
    ((eq (car-safe else) 'if)
-    `(cond (,test ,then)
-           (,(nth 1 else) ,(nth 2 else))
-           (t ,@(nthcdr 3 else))))
+    (if (equal test (nth 1 else))
+        ;; Doing a test a second time: get rid of the redundancy.
+        ;; FIXME: ideally, this should never happen because the pcase-split-*
+        ;; functions should have eliminated such things, but pcase-split-member
+        ;; is imprecise, so in practice it does happen occasionally.
+        `(if ,test ,then ,@(nthcdr 3 else))
+      `(cond (,test ,then)
+             (,(nth 1 else) ,(nth 2 else))
+             (t ,@(nthcdr 3 else)))))
    ((eq (car-safe else) 'cond)
     `(cond (,test ,then)
-           ,@(cdr else)))
+           ;; Doing a test a second time: get rid of the redundancy, as above.
+           ,@(remove (assoc test else) (cdr else))))
    (t `(if ,test ,then ,else))))
 
 (defun pcase-upat (qpattern)
@@ -276,7 +297,7 @@
    ;; A QPattern but not for a cons, can only go the `else' side.
    ((eq (car-safe pat) '\`) (cons :pcase-fail nil))))
 
-(defun pcase-split-eq (elem pat)
+(defun pcase-split-equal (elem pat)
   (cond
    ;; The same match will give the same result.
    ((and (eq (car-safe pat) '\`) (equal (cadr pat) elem))
@@ -288,11 +309,11 @@
          )
     (cons :pcase-fail nil))))
 
-(defun pcase-split-memq (elems pat)
-  ;; Based on pcase-split-eq.
+(defun pcase-split-member (elems pat)
+  ;; Based on pcase-split-equal.
   (cond
-   ;; The same match will give the same result, but we don't know how
-   ;; to check it.
+   ;; The same match (or a match of membership in a superset) will
+   ;; give the same result, but we don't know how to check it.
    ;; (???
    ;;  (cons :pcase-succeed nil))
    ;; A match for one of the elements may succeed or fail.
@@ -347,7 +368,8 @@
           (if (and (eq (car alt) 'match) (eq var (cadr alt))
                    (let ((upat (cddr alt)))
                      (and (eq (car-safe upat) '\`)
-                          (or (integerp (cadr upat)) (symbolp (cadr upat))))))
+                          (or (integerp (cadr upat)) (symbolp (cadr upat))
+                              (stringp (cadr upat))))))
               (push (cddr alt) simples)
             (push alt others))))
       (cond
@@ -380,17 +402,19 @@
        ((memq upat '(t _)) (pcase-u1 matches code vars rest))
        ((eq upat 'dontcare) :pcase-dontcare)
        ((functionp upat)  (error "Feature removed, use (pred %s)" upat))
-       ((eq (car-safe upat) 'pred)
+       ((memq (car-safe upat) '(guard pred))
         (destructuring-bind (then-rest &rest else-rest)
             (pcase-split-rest
              sym (apply-partially 'pcase-split-pred upat) rest)
-          (pcase-if (if (symbolp (cadr upat))
+          (pcase-if (if (and (eq (car upat) 'pred) (symbolp (cadr upat)))
                         `(,(cadr upat) ,sym)
                       (let* ((exp (cadr upat))
                              ;; `vs' is an upper bound on the vars we need.
                              (vs (pcase-fgrep (mapcar #'car vars) exp))
-                             (call (if (functionp exp)
-                                       `(,exp ,sym) `(,@exp ,sym))))
+                             (call (cond
+                                    ((eq 'guard (car upat)) exp)
+                                    ((functionp exp) `(,exp ,sym))
+                                    (t `(,@exp ,sym)))))
                         (if (null vs)
                             call
                           ;; Let's not replace `vars' in `exp' since it's
@@ -409,19 +433,22 @@
        ((eq (car-safe upat) '\`)
         (pcase-q1 sym (cadr upat) matches code vars rest))
        ((eq (car-safe upat) 'or)
-        (let ((all (> (length (cdr upat)) 1)))
+        (let ((all (> (length (cdr upat)) 1))
+              (memq-fine t))
           (when all
             (dolist (alt (cdr upat))
               (unless (and (eq (car-safe alt) '\`)
-                           (or (symbolp (cadr alt)) (integerp (cadr alt))))
+                           (or (symbolp (cadr alt)) (integerp (cadr alt))
+                               (setq memq-fine nil)
+                               (stringp (cadr alt))))
                 (setq all nil))))
           (if all
               ;; Use memq for (or `a `b `c `d) rather than a big tree.
               (let ((elems (mapcar 'cadr (cdr upat))))
                 (destructuring-bind (then-rest &rest else-rest)
                     (pcase-split-rest
-                     sym (apply-partially 'pcase-split-memq elems) rest)
-                  (pcase-if `(memq ,sym ',elems)
+                     sym (apply-partially 'pcase-split-member elems) rest)
+                  (pcase-if `(,(if memq-fine #'memq #'member) ,sym ',elems)
                             (pcase-u1 matches code vars then-rest)
                             (pcase-u else-rest))))
             (pcase-u1 (cons `(match ,sym ,@(cadr upat)) matches) code vars
@@ -483,10 +510,10 @@
                                   ,@matches)
                                 code vars then-rest))
                   (pcase-u else-rest)))))
-   ((or (integerp qpat) (symbolp qpat))
+   ((or (integerp qpat) (symbolp qpat) (stringp qpat))
     (destructuring-bind (then-rest &rest else-rest)
-        (pcase-split-rest sym (apply-partially 'pcase-split-eq qpat) rest)
-      (pcase-if `(eq ,sym ',qpat)
+        (pcase-split-rest sym (apply-partially 'pcase-split-equal qpat) rest)
+      (pcase-if `(,(if (stringp qpat) #'equal #'eq) ,sym ',qpat)
                 (pcase-u1 matches code vars then-rest)
                 (pcase-u else-rest))))
    (t (error "Unkown QPattern %s" qpat))))
--- a/lisp/emacs-lisp/regexp-opt.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/emacs-lisp/regexp-opt.el	Mon Nov 08 14:19:54 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/smie.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/emacs-lisp/smie.el	Mon Nov 08 14:19:54 2010 +0900
@@ -52,9 +52,9 @@
 ;;   error because the parser just automatically does something.  Better yet,
 ;;   we can afford to use a sloppy grammar.
 
-;; The development (especially the parts building the 2D precedence
-;; tables and then computing the precedence levels from it) is largely
-;; inspired from page 187-194 of "Parsing techniques" by Dick Grune
+;; A good background to understand the development (especially the parts
+;; building the 2D precedence tables and then computing the precedence levels
+;; from it) can be found in pages 187-194 of "Parsing techniques" by Dick Grune
 ;; and Ceriel Jacobs (BookBody.pdf available at
 ;; http://www.cs.vu.nl/~dick/PTAPG.html).
 ;;
@@ -70,6 +70,10 @@
 
 (eval-when-compile (require 'cl))
 
+(defgroup smie nil
+  "Simple Minded Indentation Engine."
+  :group 'languages)
+
 (defvar comment-continue)
 (declare-function comment-string-strip "newcomment" (str beforep afterp))
 
@@ -87,9 +91,9 @@
 ;; - a 2 dimensional precedence table (key word "prec2"), is a 2D
 ;;   table recording the precedence relation (can be `<', `=', `>', or
 ;;   nil) between each pair of tokens.
-;; - a precedence-level table (key word "levels"), while is a alist
+;; - a precedence-level table (key word "grammar"), which is a alist
 ;;   giving for each token its left and right precedence level (a
-;;   number or nil).  This is used in `smie-op-levels'.
+;;   number or nil).  This is used in `smie-grammar'.
 ;; The prec2 tables are only intermediate data structures: the source
 ;; code normally provides a mix of BNF and precs tables, and then
 ;; turns them into a levels table, which is what's used by the rest of
@@ -109,7 +113,8 @@
           (display-warning 'smie (format "Conflict: %s %s/%s %s" x old val y)))
       (puthash key val table))))
 
-(defun smie-precs-precedence-table (precs)
+(put 'smie-precs->prec2 'pure t)
+(defun smie-precs->prec2 (precs)
   "Compute a 2D precedence table from a list of precedences.
 PRECS should be a list, sorted by precedence (e.g. \"+\" will
 come before \"*\"), of elements of the form \(left OP ...)
@@ -132,6 +137,7 @@
                 (smie-set-prec2tab prec2-table other-op op op1)))))))
     prec2-table))
 
+(put 'smie-merge-prec2s 'pure t)
 (defun smie-merge-prec2s (&rest tables)
   (if (null (cdr tables))
       (car tables)
@@ -147,7 +153,8 @@
                  table))
       prec2)))
 
-(defun smie-bnf-precedence-table (bnf &rest precs)
+(put 'smie-bnf->prec2 'pure t)
+(defun smie-bnf->prec2 (bnf &rest precs)
   (let ((nts (mapcar 'car bnf))         ;Non-terminals
         (first-ops-table ())
         (last-ops-table ())
@@ -155,7 +162,7 @@
         (last-nts-table ())
         (prec2 (make-hash-table :test 'equal))
         (override (apply 'smie-merge-prec2s
-                         (mapcar 'smie-precs-precedence-table precs)))
+                         (mapcar 'smie-precs->prec2 precs)))
         again)
     (dolist (rules bnf)
       (let ((nt (car rules))
@@ -231,8 +238,9 @@
            (t (smie-set-prec2tab prec2 (car rhs) (cadr rhs) '= override)))
           (setq rhs (cdr rhs)))))
     ;; Keep track of which tokens are openers/closer, so they can get a nil
-    ;; precedence in smie-prec2-levels.
+    ;; precedence in smie-prec2->grammar.
     (puthash :smie-open/close-alist (smie-bnf-classify bnf) prec2)
+    (puthash :smie-closer-alist (smie-bnf-closer-alist bnf) prec2)
     prec2))
 
 ;; (defun smie-prec2-closer-alist (prec2 include-inners)
@@ -314,7 +322,7 @@
               (unless (member term nts)
                 (pushnew (cons (car rhs) term) alist :test #'equal)))))))
     (nreverse alist)))
-    
+
 (defun smie-bnf-classify (bnf)
   "Return a table classifying terminals.
 Each terminal can either be an `opener', a `closer', or neither."
@@ -359,7 +367,7 @@
               (push (cons (car path) (cons (cdr cst) (cdr path)))
                     paths))))))
     (cons (car cycle) (nreverse (cdr cycle)))))
-            
+
 (defun smie-debug--describe-cycle (table cycle)
   (let ((names
          (mapcar (lambda (val)
@@ -377,16 +385,11 @@
      (append names (list (car names)))
      " < ")))
 
-(defun smie-prec2-levels (prec2)
-  ;; FIXME: Rather than only return an alist of precedence levels, we should
-  ;; also extract other useful data from it:
-  ;; - better default indentation rules (i.e. non-zero indentation after inner
-  ;;   keywords like the "in" of "let..in..end") for smie-indent-after-keyword.
-  ;; Of course, maybe those things would be even better handled in the
-  ;; bnf->prec function.
+(put 'smie-prec2->grammar 'pure t)
+(defun smie-prec2->grammar (prec2)
   "Take a 2D precedence table and turn it into an alist of precedence levels.
-PREC2 is a table as returned by `smie-precs-precedence-table' or
-`smie-bnf-precedence-table'."
+PREC2 is a table as returned by `smie-precs->prec2' or
+`smie-bnf->prec2'."
   ;; For each operator, we create two "variables" (corresponding to
   ;; the left and right precedence level), which are represented by
   ;; cons cells.  Those are the very cons cells that appear in the
@@ -479,12 +482,15 @@
                       (eq 'closer (cdr (assoc (car x) classification-table))))
             (setf (nth 2 x) i)
             (incf i)))))                ;See other (incf i) above.
+    (let ((ca (gethash :smie-closer-alist prec2)))
+      (when ca (push (cons :smie-closer-alist ca) table)))
     table))
 
 ;;; Parsing using a precedence level table.
 
-(defvar smie-op-levels 'unset
+(defvar smie-grammar 'unset
   "List of token parsing info.
+This list is normally built by `smie-prec2->grammar'.
 Each element is of the form (TOKEN LEFT-LEVEL RIGHT-LEVEL).
 Parsing is done using an operator precedence parser.
 LEFT-LEVEL and RIGHT-LEVEL can be either numbers or nil, where nil
@@ -527,7 +533,7 @@
 (defun smie--associative-p (toklevels)
   ;; in "a + b + c" we want to stop at each +, but in
   ;; "if a then b elsif c then d else c" we don't want to stop at each keyword.
-  ;; To distinguish the two cases, we made smie-prec2-levels choose
+  ;; To distinguish the two cases, we made smie-prec2->grammar choose
   ;; different levels for each part of "if a then b else c", so that
   ;; by checking if the left-level is equal to the right level, we can
   ;; figure out that it's an associative operator.
@@ -557,7 +563,7 @@
       (while
           (let* ((pos (point))
                  (token (funcall next-token))
-                 (toklevels (cdr (assoc token smie-op-levels))))
+                 (toklevels (cdr (assoc token smie-grammar))))
             (cond
              ((null toklevels)
               (when (zerop (length token))
@@ -699,7 +705,7 @@
                (string (cdr (syntax-after (point))))
              (let* ((open (funcall smie-forward-token-function))
                     (closer (cdr (assoc open smie-closer-alist)))
-                    (levels (list (assoc open smie-op-levels)))
+                    (levels (list (assoc open smie-grammar)))
                     (seen '())
                     (found '()))
                (cond
@@ -711,13 +717,11 @@
                 ((or (equal levels '(nil)) (nth 1 (car levels)))
                  (error "Doesn't look like a block"))
                 (t
-                 ;; FIXME: With grammars like Octave's, every closer ("end",
-                 ;; "endif", "endwhile", ...) has the same level, so we'd need
-                 ;; to look at the BNF or at least at the 2D prec-table, in
-                 ;; order to find the right closer for a given opener.
+                 ;; Now that smie-setup automatically sets smie-closer-alist
+                 ;; from the BNF, this is not really needed any more.
                  (while levels
                    (let ((level (pop levels)))
-                     (dolist (other smie-op-levels)
+                     (dolist (other smie-grammar)
                        (when (and (eq (nth 2 level) (nth 1 other))
                                   (not (memq other seen)))
                          (push other seen)
@@ -752,7 +756,7 @@
       (while
           (let* ((pos (point))
                  (token (funcall next-token))
-                 (levels (assoc token smie-op-levels)))
+                 (levels (assoc token smie-grammar)))
             (cond
              ((zerop (length token))
               (if (if (< inc 0) (looking-back "\\s(\\|\\s)" (1- (point)))
@@ -783,7 +787,8 @@
 (defcustom smie-blink-matching-inners t
   "Whether SMIE should blink to matching opener for inner keywords.
 If non-nil, it will blink not only for \"begin..end\" but also for \"if...else\"."
-  :type 'boolean)
+  :type 'boolean
+  :group 'smie)
 
 (defun smie-blink-matching-check (start end)
   (save-excursion
@@ -803,14 +808,22 @@
 (defun smie-blink-matching-open ()
   "Blink the matching opener when applicable.
 This uses SMIE's tables and is expected to be placed on `post-self-insert-hook'."
-  (when (and blink-matching-paren
-             smie-closer-alist                     ; Optimization.
-             (eq (char-before) last-command-event) ; Sanity check.
-             (memq last-command-event smie-blink-matching-triggers)
-             (not (nth 8 (syntax-ppss))))
-    (save-excursion
-      (let ((pos (point))
-            (token (funcall smie-backward-token-function)))
+  (let ((pos (point))                   ;Position after the close token.
+        token)
+    (when (and blink-matching-paren
+               smie-closer-alist                     ; Optimization.
+               (or (eq (char-before) last-command-event) ;; Sanity check.
+                   (save-excursion
+                     (or (progn (skip-chars-backward " \t")
+                                (setq pos (point))
+                                (eq (char-before) last-command-event))
+                         (progn (skip-chars-backward " \n\t")
+                                (setq pos (point))
+                                (eq (char-before) last-command-event)))))
+               (memq last-command-event smie-blink-matching-triggers)
+               (not (nth 8 (syntax-ppss))))
+      (save-excursion
+        (setq token (funcall smie-backward-token-function))
         (when (and (eq (point) (1- pos))
                    (= 1 (length token))
                    (not (rassoc token smie-closer-alist)))
@@ -818,17 +831,20 @@
           ;; closers (e.g. ?\; in Octave mode), so go back to the
           ;; previous token.
           (setq pos (point))
-          (setq token (save-excursion
-                        (funcall smie-backward-token-function))))
+          (setq token (funcall smie-backward-token-function)))
         (when (rassoc token smie-closer-alist)
           ;; We're after a close token.  Let's still make sure we
           ;; didn't skip a comment to find that token.
           (funcall smie-forward-token-function)
           (when (and (save-excursion
-                       ;; Trigger can be SPC, or reindent.
-                       (skip-chars-forward " \n\t")
+                       ;; Skip the trigger char, if applicable.
+                       (if (eq (char-after) last-command-event)
+                           (forward-char 1))
+                       (if (eq ?\n last-command-event)
+                           ;; Skip any auto-indentation, if applicable.
+                           (skip-chars-forward " \t"))
                        (>= (point) pos))
-                     ;; If token ends with a trigger char, so don't blink for
+                     ;; If token ends with a trigger char, don't blink for
                      ;; anything else than this trigger char, lest we'd blink
                      ;; both when inserting the trigger char and when
                      ;; inserting a subsequent trigger char like SPC.
@@ -836,7 +852,7 @@
                          (not (memq (char-before)
                                     smie-blink-matching-triggers)))
                      (or smie-blink-matching-inners
-                         (null (nth 2 (assoc token smie-op-levels)))))
+                         (null (nth 2 (assoc token smie-grammar)))))
             ;; The major mode might set blink-matching-check-function
             ;; buffer-locally so that interactive calls to
             ;; blink-matching-open work right, but let's not presume
@@ -848,192 +864,250 @@
 
 (defcustom smie-indent-basic 4
   "Basic amount of indentation."
-  :type 'integer)
+  :type 'integer
+  :group 'smie)
 
-(defvar smie-indent-rules 'unset
-  ;; TODO: For SML, we need more rule formats, so as to handle
-  ;;   structure Foo =
-  ;;      Bar (toto)
-  ;; and
-  ;;   structure Foo =
-  ;;   struct ... end
-  ;; I.e. the indentation after "=" depends on the parent ("structure")
-  ;; as well as on the following token ("struct").
-  "Rules of the following form.
-\((:before . TOK) . OFFSET-RULES)	how to indent TOK itself.
-\(TOK . OFFSET-RULES)	how to indent right after TOK.
-\(list-intro . TOKENS)	declare TOKENS as being followed by what may look like
-			  a funcall but is just a sequence of expressions.
-\(t . OFFSET)		basic indentation step.
-\(args . OFFSET)		indentation of arguments.
-\((T1 . T2) OFFSET)	like ((:before . T2) (:parent T1 OFFSET)).
+(defvar smie-rules-function 'ignore
+  "Function providing the indentation rules.
+It takes two arguments METHOD and ARG where the meaning of ARG
+and the expected return value depends on METHOD.
+METHOD can be:
+- :after, in which case ARG is a token and the function should return the
+  OFFSET to use for indentation after ARG.
+- :before, in which case ARG is a token and the function should return the
+  OFFSET to use to indent ARG itself.
+- :elem, in which case the function should return either:
+  - the offset to use to indent function arguments (ARG = `arg')
+  - the basic indentation step (ARG = `basic').
+- :list-intro, in which case ARG is a token and the function should return
+  non-nil if TOKEN is followed by a list of expressions (not separated by any
+  token) rather than an expression.
 
-OFFSET-RULES is a list of elements which can each either be:
-
-\(:hanging . OFFSET-RULES)	if TOK is hanging, use OFFSET-RULES.
-\(:parent PARENT . OFFSET-RULES) if TOK's parent is PARENT, use OFFSET-RULES.
-\(:next TOKEN . OFFSET-RULES)	if TOK is followed by TOKEN, use OFFSET-RULES.
-\(:prev TOKEN . OFFSET-RULES)	if TOK is preceded by TOKEN, use
-\(:bolp . OFFSET-RULES)		If TOK is first on a line, use OFFSET-RULES.
-OFFSET				the offset to use.
+When ARG is a token, the function is called with point just before that token.
+A return value of nil always means to fallback on the default behavior, so the
+function should return nil for arguments it does not expect.
 
-PARENT can be either the name of the parent or a list of such names.
+OFFSET can be:
+nil				use the default indentation rule.
+`(column . COLUMN)		indent to column COLUMN.
+NUMBER				offset by NUMBER, relative to a base token
+				which is the current token for :after and
+				its parent for :before.
 
-OFFSET can be of the form:
-`point'				align with the token.
-`parent'				align with the parent.
-NUMBER				offset by NUMBER.
-\(+ OFFSETS...)			use the sum of OFFSETS.
-VARIABLE			use the value of VARIABLE as offset.
-
-The precise meaning of `point' depends on various details: it can
-either mean the position of the token we're indenting, or the
-position of its parent, or the position right after its parent.
+The functions whose name starts with \"smie-rule-\" are helper functions
+designed specifically for use in this function.")
 
-A nil offset for indentation after an opening token defaults
-to `smie-indent-basic'.")
-
+(defalias 'smie-rule-hanging-p 'smie-indent--hanging-p)
 (defun smie-indent--hanging-p ()
-  ;; A hanging keyword is one that's at the end of a line except it's not at
-  ;; the beginning of a line.
-  (and (save-excursion
-         (when (zerop (length (funcall smie-forward-token-function)))
-           ;; Could be an open-paren.
-           (forward-char 1))
-         (skip-chars-forward " \t")
-         (eolp))
-       (not (smie-indent--bolp))))
+  "Return non-nil if the current token is \"hanging\".
+A hanging keyword is one that's at the end of a line except it's not at
+the beginning of a line."
+  (and (not (smie-indent--bolp))
+       (save-excursion
+         (<= (line-end-position)
+             (progn
+               (when (zerop (length (funcall smie-forward-token-function)))
+                 ;; Could be an open-paren.
+                 (forward-char 1))
+               (skip-chars-forward " \t")
+               (or (eolp)
+                   (and (looking-at comment-start-skip)
+                        (forward-comment (point-max))))
+               (point))))))
 
+(defalias 'smie-rule-bolp 'smie-indent--bolp)
 (defun smie-indent--bolp ()
+  "Return non-nil if the current token is the first on the line."
   (save-excursion (skip-chars-backward " \t") (bolp)))
 
+;; Dynamically scoped.
+(defvar smie--parent) (defvar smie--after) (defvar smie--token)
+
+(defun smie-indent--parent ()
+  (or smie--parent
+      (save-excursion
+        (let* ((pos (point))
+               (tok (funcall smie-forward-token-function)))
+          (unless (cadr (assoc tok smie-grammar))
+            (goto-char pos))
+          (setq smie--parent
+                (smie-backward-sexp 'halfsexp))))))
+
+(defun smie-rule-parent-p (&rest parents)
+  "Return non-nil if the current token's parent is among PARENTS.
+Only meaningful when called from within `smie-rules-function'."
+  (member (nth 2 (smie-indent--parent)) parents))
+
+(defun smie-rule-next-p (&rest tokens)
+  "Return non-nil if the next token is among TOKENS.
+Only meaningful when called from within `smie-rules-function'."
+  (let ((next
+         (save-excursion
+           (unless smie--after
+             (smie-indent-forward-token) (setq smie--after (point)))
+           (goto-char smie--after)
+           (smie-indent-forward-token))))
+    (member (car next) tokens)))
+
+(defun smie-rule-prev-p (&rest tokens)
+  "Return non-nil if the previous token is among TOKENS."
+  (let ((prev (save-excursion
+                (smie-indent-backward-token))))
+    (member (car prev) tokens)))
+
+(defun smie-rule-sibling-p ()
+  "Return non-nil if the parent is actually a sibling.
+Only meaningful when called from within `smie-rules-function'."
+  (eq (car (smie-indent--parent))
+      (cadr (assoc smie--token smie-grammar))))
+
+(defun smie-rule-parent (&optional offset)
+  "Align with parent.
+If non-nil, OFFSET should be an integer giving an additional offset to apply.
+Only meaningful when called from within `smie-rules-function'."
+  (save-excursion
+    (goto-char (cadr (smie-indent--parent)))
+    (cons 'column
+          (+ (or offset 0)
+             (if (smie-indent--hanging-p)
+                 (smie-indent-virtual) (current-column))))))  
+
+(defvar smie-rule-separator-outdent 2)
+
+(defun smie-indent--separator-outdent ()
+  ;; FIXME: Here we actually have several reasonable behaviors.
+  ;; E.g. for a parent token of "FOO" and a separator ";" we may want to:
+  ;; 1- left-align ; with FOO.
+  ;; 2- right-align ; with FOO.
+  ;; 3- align content after ; with content after FOO.
+  ;; 4- align content plus add/remove spaces so as to align ; with FOO.
+  ;; Currently, we try to align the contents (option 3) which actually behaves
+  ;; just like option 2 (if the number of spaces after FOO and ; is equal).
+  (let ((afterpos (save-excursion
+                    (let ((tok (funcall smie-forward-token-function)))
+                      (unless tok
+                        (with-demoted-errors
+                          (error "smie-rule-separator: can't skip token %s"
+                                 smie--token))))
+                    (skip-chars-forward " ")
+                    (unless (eolp) (point)))))
+    (or (and afterpos
+             ;; This should always be true, unless
+             ;; smie-forward-token-function skipped a \n.
+             (< afterpos (line-end-position))
+             (- afterpos (point)))
+        smie-rule-separator-outdent)))
+
+(defun smie-rule-separator (method)
+  "Indent current token as a \"separator\".
+By \"separator\", we mean here a token whose sole purpose is to separate
+various elements within some enclosing syntactic construct, and which does
+not have any semantic significance in itself (i.e. it would typically no exist
+as a node in an abstract syntax tree).
+Such a token is expected to have an associative syntax and be closely tied
+to its syntactic parent.  Typical examples are \",\" in lists of arguments
+\(enclosed inside parentheses), or \";\" in sequences of instructions (enclosed
+in a {..} or begin..end block).
+METHOD should be the method name that was passed to `smie-rules-function'.
+Only meaningful when called from within `smie-rules-function'."
+  ;; FIXME: The code below works OK for cases where the separators
+  ;; are placed consistently always at beginning or always at the end,
+  ;; but not if some are at the beginning and others are at the end.
+  ;; I.e. it gets confused in cases such as:
+  ;;     (  a
+  ;;     ,  a,
+  ;;        b
+  ;;     ,  c,
+  ;;        d
+  ;;     )
+  ;;
+  ;; Assuming token is associative, the default rule for associative
+  ;; tokens (which assumes an infix operator) works fine for many cases.
+  ;; We mostly need to take care of the case where token is at beginning of
+  ;; line, in which case we want to align it with its enclosing parent.
+  (cond
+   ((and (eq method :before) (smie-rule-bolp) (not (smie-rule-sibling-p)))
+    ;; FIXME: Rather than consult the number of spaces, we could *set* the
+    ;; number of spaces so as to align the separator with the close-paren
+    ;; while aligning the content with the rest.
+    (let ((parent-col
+           (save-excursion
+             (goto-char (cadr smie--parent))
+             (if (smie-indent--hanging-p)
+                 (smie-indent-virtual) (current-column))))
+          (parent-pos-col     ;FIXME: we knew this when computing smie--parent.
+           (save-excursion
+             (goto-char (cadr smie--parent))
+             (smie-indent-forward-token)
+             (forward-comment (point-max))
+             (current-column))))
+      (cons 'column
+            (max parent-col
+                 (min parent-pos-col
+                      (- parent-pos-col (smie-indent--separator-outdent)))))))
+   ((and (eq method :after) (smie-indent--bolp))
+    (smie-indent--separator-outdent))))
+
 (defun smie-indent--offset (elem)
-  (or (cdr (assq elem smie-indent-rules))
-      (cdr (assq t smie-indent-rules))
+  (or (funcall smie-rules-function :elem elem)
+      (if (not (eq elem 'basic))
+          (funcall smie-rules-function :elem 'basic))
       smie-indent-basic))
 
-(defvar smie-indent-debug-log)
-
-(defun smie-indent--offset-rule (tokinfo &optional after parent)
-  "Apply the OFFSET-RULES in TOKINFO.
-Point is expected to be right in front of the token corresponding to TOKINFO.
-If computing the indentation after the token, then AFTER is the position
-after the token, otherwise it should be nil.
-PARENT if non-nil should be the parent info returned by `smie-backward-sexp'."
-  (let ((rules (cdr tokinfo))
-        next prev
-        offset)
-    (while (consp rules)
-      (let ((rule (pop rules)))
-        (cond
-         ((not (consp rule)) (setq offset rule))
-         ((eq (car rule) '+) (setq offset rule))
-         ((eq (car rule) :hanging)
-          (when (smie-indent--hanging-p)
-            (setq rules (cdr rule))))
-         ((eq (car rule) :bolp)
-          (when (smie-indent--bolp)
-            (setq rules (cdr rule))))
-         ((eq (car rule) :eolp)
-          (unless after
-            (error "Can't use :eolp in :before indentation rules"))
-          (when (> after (line-end-position))
-            (setq rules (cdr rule))))
-         ((eq (car rule) :prev)
-          (unless prev
-            (save-excursion
-              (setq prev (smie-indent-backward-token))))
-          (when (equal (car prev) (cadr rule))
-            (setq rules (cddr rule))))
-         ((eq (car rule) :next)
-          (unless next
-            (unless after
-              (error "Can't use :next in :before indentation rules"))
-            (save-excursion
-              (goto-char after)
-              (setq next (smie-indent-forward-token))))
-          (when (equal (car next) (cadr rule))
-            (setq rules (cddr rule))))
-         ((eq (car rule) :parent)
-          (unless parent
-            (save-excursion
-              (if after (goto-char after))
-              (setq parent (smie-backward-sexp 'halfsexp))))
-          (when (if (listp (cadr rule))
-                    (member (nth 2 parent) (cadr rule))
-                  (equal (nth 2 parent) (cadr rule)))
-            (setq rules (cddr rule))))
-         (t (error "Unknown rule %s for indentation of %s"
-                   rule (car tokinfo))))))
-    ;; If `offset' is not set yet, use `rules' to handle the case where
-    ;; the tokinfo uses the old-style ((PARENT . TOK). OFFSET).
-    (unless offset (setq offset rules))
-    (when (boundp 'smie-indent-debug-log)
-      (push (list (point) offset tokinfo) smie-indent-debug-log))
-    offset))
-
-(defun smie-indent--column (offset &optional base parent virtual-point)
-  "Compute the actual column to use for a given OFFSET.
-BASE is the base position to use, and PARENT is the parent info, if any.
-If VIRTUAL-POINT is non-nil, then `point' is virtual."
-  (cond
-   ((eq (car-safe offset) '+)
-    (apply '+ (mapcar (lambda (offset) (smie-indent--column offset nil parent))
-                      (cdr offset))))
-   ((integerp offset)
-    (+ offset
-       (case base
-         ((nil) 0)
-         (parent (goto-char (cadr parent))
-                 (smie-indent-virtual))
-         (t
-          (goto-char base)
-          ;; For indentation after "(let" in SML-mode, we end up accumulating
-          ;; the offset of "(" and the offset of "let", so we use `min' to try
-          ;; and get it right either way.
-          (min (smie-indent-virtual) (current-column))))))
-   ((eq offset 'point)
-    ;; In indent-keyword, if we're indenting `then' wrt `if', we want to use
-    ;; indent-virtual rather than use just current-column, so that we can
-    ;; apply the (:before . "if") rule which does the "else if" dance in SML.
-    ;; But in other cases, we do not want to use indent-virtual
-    ;; (e.g. indentation of "*" w.r.t "+", or ";" wrt "(").  We could just
-    ;; always use indent-virtual and then have indent-rules say explicitly
-    ;; to use `point' after things like "(" or "+" when they're not at EOL,
-    ;; but you'd end up with lots of those rules.
-    ;; So we use a heuristic here, which is that we only use virtual if
-    ;; the parent is tightly linked to the child token (they're part of
-    ;; the same BNF rule).
-    (if (and virtual-point (null (car parent))) ;Black magic :-(
-        (smie-indent-virtual) (current-column)))
-   ((eq offset 'parent)
-    (unless parent
-      (setq parent (or (smie-backward-sexp 'halfsexp) :notfound)))
-    (if (consp parent) (goto-char (cadr parent)))
-    (smie-indent-virtual))
-   ((eq offset nil) nil)
-   ((and (symbolp offset) (boundp 'offset))
-    (smie-indent--column (symbol-value offset) base parent virtual-point))
-   (t (error "Unknown indentation offset %s" offset))))
+(defun smie-indent--rule (method token
+                          ;; FIXME: Too many parameters.
+                          &optional after parent base-pos)
+  "Compute indentation column according to `indent-rule-functions'.
+METHOD and TOKEN are passed to `indent-rule-functions'.
+AFTER is the position after TOKEN, if known.
+PARENT is the parent info returned by `smie-backward-sexp', if known.
+BASE-POS is the position relative to which offsets should be applied."
+  ;; This is currently called in 3 cases:
+  ;; - :before opener, where rest=nil but base-pos could as well be parent.
+  ;; - :before other, where
+  ;;                  ; after=nil
+  ;;                  ; parent is set
+  ;;                  ; base-pos=parent
+  ;; - :after tok, where
+  ;;                  ; after is set; parent=nil; base-pos=point;
+  (save-excursion
+    (let ((offset
+           (let ((smie--parent parent)
+                 (smie--token token)
+                 (smie--after after))
+             (funcall smie-rules-function method token))))
+      (cond
+       ((not offset) nil)
+       ((eq (car-safe offset) 'column) (cdr offset))
+       ((integerp offset)
+        (+ offset
+           (if (null base-pos) 0
+             (goto-char base-pos)
+             (if (smie-indent--hanging-p)
+                 (smie-indent-virtual) (current-column)))))
+       (t (error "Unknown indentation offset %s" offset))))))
 
 (defun smie-indent-forward-token ()
   "Skip token forward and return it, along with its levels."
   (let ((tok (funcall smie-forward-token-function)))
     (cond
-     ((< 0 (length tok)) (assoc tok smie-op-levels))
-     ((looking-at "\\s(")
+     ((< 0 (length tok)) (assoc tok smie-grammar))
+     ((looking-at "\\s(\\|\\s)\\(\\)")
       (forward-char 1)
-      (list (buffer-substring (1- (point)) (point)) nil 0)))))
+      (cons (buffer-substring (1- (point)) (point))
+            (if (match-end 1) '(0 nil) '(nil 0)))))))
 
 (defun smie-indent-backward-token ()
   "Skip token backward and return it, along with its levels."
-  (let ((tok (funcall smie-backward-token-function)))
+  (let ((tok (funcall smie-backward-token-function))
+        class)
     (cond
-     ((< 0 (length tok)) (assoc tok smie-op-levels))
-     ;; 4 == Open paren syntax.
-     ((eq 4 (syntax-class (syntax-after (1- (point)))))
+     ((< 0 (length tok)) (assoc tok smie-grammar))
+     ;; 4 == open paren syntax, 5 == close.
+     ((memq (setq class (syntax-class (syntax-after (1- (point))))) '(4 5))
       (forward-char -1)
-      (list (buffer-substring (point) (1+ (point))) nil 0)))))
+      (cons (buffer-substring (point) (1+ (point)))
+            (if (eq class 4) '(nil 0) '(0 nil)))))))
 
 (defun smie-indent-virtual ()
   ;; We used to take an optional arg (with value :not-hanging) to specify that
@@ -1101,32 +1175,14 @@
               ;; For an open-paren-like thingy at BOL, always indent only
               ;; based on other rules (typically smie-indent-after-keyword).
               nil)
+             ;; We're only ever here for virtual-indent.
+             ((smie-indent--rule :before token))
              (t
-              ;; We're only ever here for virtual-indent, which is why
-              ;; we can use (current-column) as answer for `point'.
-              (let* ((tokinfo (or (assoc (cons :before token)
-                                         smie-indent-rules)
-                                  ;; By default use point unless we're hanging.
-                                  `((:before . ,token) (:hanging nil) point)))
-                     ;; (after (prog1 (point) (goto-char pos)))
-                     (offset (smie-indent--offset-rule tokinfo)))
-                (smie-indent--column offset)))))
+              ;; By default use point unless we're hanging.
+              (unless (smie-indent--hanging-p) (current-column)))))
 
         ;; FIXME: This still looks too much like black magic!!
-        ;; FIXME: Rather than a bunch of rules like (PARENT . TOKEN), we
-        ;; want a single rule for TOKEN with different cases for each PARENT.
-        (let* ((parent (smie-backward-sexp 'halfsexp))
-               (tokinfo
-                (or (assoc (cons (caddr parent) token)
-                           smie-indent-rules)
-                    (assoc (cons :before token) smie-indent-rules)
-                    ;; Default rule.
-                    `((:before . ,token)
-                      ;; (:parent open 0)
-                      point)))
-               (offset (save-excursion
-                         (goto-char pos)
-                         (smie-indent--offset-rule tokinfo nil parent))))
+        (let* ((parent (smie-backward-sexp 'halfsexp)))
           ;; Different behaviors:
           ;; - align with parent.
           ;; - parent + offset.
@@ -1149,21 +1205,15 @@
             ;; maybe when an infix or close-paren is at the beginning
             ;; of a buffer.
             nil)
+           ((save-excursion
+              (goto-char pos)
+              (smie-indent--rule :before token nil parent (cadr parent))))
            ((eq (car parent) (car toklevels))
-            ;; We bumped into a same-level operator. align with it.
+            ;; We bumped into a same-level operator; align with it.
             (if (and (smie-indent--bolp) (/= (point) pos)
                      (save-excursion
                        (goto-char (goto-char (cadr parent)))
-                       (not (smie-indent--bolp)))
-                     ;; Check the offset of `token' rather then its parent
-                     ;; because its parent may have used a special rule.  E.g.
-                     ;;    function foo;
-                     ;;      line2;
-                     ;;      line3;
-                     ;; The ; on the first line had a special rule, but when
-                     ;; indenting line3, we don't care about it and want to
-                     ;; align with line2.
-                     (memq offset '(point nil)))
+                       (not (smie-indent--bolp))))
                 ;; If the parent is at EOL and its children are indented like
                 ;; itself, then we can just obey the indentation chosen for the
                 ;; child.
@@ -1190,19 +1240,27 @@
               ;;    -> d
               ;; So as to align with the earliest appropriate place.
               (smie-indent-virtual)))
-           (tokinfo
-            (if (and (= (point) pos) (smie-indent--bolp)
-                     (or (eq offset 'point)
-                         (and (consp offset) (memq 'point offset))))
+           (t
+            (if (and (= (point) pos) (smie-indent--bolp))
                 ;; Since we started at BOL, we're not computing a virtual
                 ;; indentation, and we're still at the starting point, so
                 ;; we can't use `current-column' which would cause
-                ;; indentation to depend on itself.
+                ;; indentation to depend on itself and we can't use
+                ;; smie-indent-virtual since that would be an inf-loop.
                 nil
-              (smie-indent--column offset 'parent parent
-                                  ;; If we're still at pos, indent-virtual
-                                  ;; will inf-loop.
-                                  (unless (= (point) pos) 'virtual))))))))))
+              ;; In indent-keyword, if we're indenting `then' wrt `if', we
+              ;; want to use indent-virtual rather than use just
+              ;; current-column, so that we can apply the (:before . "if")
+              ;; rule which does the "else if" dance in SML.  But in other
+              ;; cases, we do not want to use indent-virtual (e.g. indentation
+              ;; of "*" w.r.t "+", or ";" wrt "(").  We could just always use
+              ;; indent-virtual and then have indent-rules say explicitly to
+              ;; use `point' after things like "(" or "+" when they're not at
+              ;; EOL, but you'd end up with lots of those rules.
+              ;; So we use a heuristic here, which is that we only use virtual
+              ;; if the parent is tightly linked to the child token (they're
+              ;; part of the same BNF rule).
+              (if (car parent) (current-column) (smie-indent-virtual))))))))))
 
 (defun smie-indent-comment ()
   "Compute indentation of a comment."
@@ -1254,27 +1312,18 @@
   (save-excursion
     (let* ((pos (point))
            (toklevel (smie-indent-backward-token))
-           (tok (car toklevel))
-           (tokinfo (assoc tok smie-indent-rules)))
-      ;; Set some default indent rules.
-      (if (and toklevel (null (cadr toklevel)) (null tokinfo))
-          (setq tokinfo (list (car toklevel))))
-      ;; (if (and tokinfo (null toklevel))
-      ;;     (error "Token %S has indent rule but has no parsing info" tok))
-      (when toklevel
-        (unless tokinfo
-          ;; The default indentation after a keyword/operator is 0 for
-          ;; infix and t for prefix.
-          ;; Using the BNF syntax, we could come up with better
-          ;; defaults, but we only have the precedence levels here.
-          (setq tokinfo (list tok 'default-rule
-                              (if (cadr toklevel) 0 (smie-indent--offset t)))))
-        (let ((offset
-               (or (smie-indent--offset-rule tokinfo pos)
-                   (smie-indent--offset t))))
-          (let ((before (point)))
-            (goto-char pos)
-            (smie-indent--column offset before)))))))
+           (tok (car toklevel)))
+      (cond
+       ((null toklevel) nil)
+       ((smie-indent--rule :after tok pos nil (point)))
+       ;; The default indentation after a keyword/operator is
+       ;; 0 for infix, t for prefix, and use another rule
+       ;; for postfix.
+       ((null (nth 2 toklevel)) nil)        ;A closer.
+       ((or (null (nth 1 toklevel))         ;An opener.
+            (rassoc tok smie-closer-alist)) ;An inner.
+        (+ (smie-indent-virtual) (smie-indent--offset 'basic))) ;
+       (t (smie-indent-virtual))))))    ;An infix.
 
 (defun smie-indent-exps ()
   ;; Indentation of sequences of simple expressions without
@@ -1301,9 +1350,10 @@
       (save-excursion
         ;; Figure out if the atom we just skipped is an argument rather
         ;; than a function.
-        (setq arg (or (null (car (smie-backward-sexp)))
-                      (member (funcall smie-backward-token-function)
-                              (cdr (assoc 'list-intro smie-indent-rules))))))
+        (setq arg
+              (or (null (car (smie-backward-sexp)))
+                  (funcall smie-rules-function :list-intro
+                           (funcall smie-backward-token-function)))))
       (cond
        ((null positions)
         ;; We're the first expression of the list.  In that case, the
@@ -1322,7 +1372,6 @@
        (positions
         ;; We're the first arg.
         (goto-char (car positions))
-        ;; FIXME: Use smie-indent--column.
         (+ (smie-indent--offset 'args)
            ;; We used to use (smie-indent-virtual), but that
            ;; doesn't seem right since it might then indent args less than
@@ -1331,9 +1380,9 @@
 
 (defvar smie-indent-functions
   '(smie-indent-fixindent smie-indent-bob smie-indent-close
-    smie-indent-comment smie-indent-comment-continue smie-indent-comment-close
-    smie-indent-comment-inside smie-indent-keyword smie-indent-after-keyword
-    smie-indent-exps)
+                          smie-indent-comment smie-indent-comment-continue smie-indent-comment-close
+                          smie-indent-comment-inside smie-indent-keyword smie-indent-after-keyword
+                          smie-indent-exps)
   "Functions to compute the indentation.
 Each function is called with no argument, shouldn't move point, and should
 return either nil if it has no opinion, or an integer representing the column
@@ -1347,13 +1396,13 @@
   "Indent current line using the SMIE indentation engine."
   (interactive)
   (let* ((savep (point))
-	 (indent (condition-case-no-debug nil
-		     (save-excursion
-                       (forward-line 0)
-                       (skip-chars-forward " \t")
-                       (if (>= (point) savep) (setq savep nil))
-                       (or (smie-indent-calculate) 0))
-                   (error 0))))
+	 (indent (or (with-demoted-errors
+                       (save-excursion
+                         (forward-line 0)
+                         (skip-chars-forward " \t")
+                         (if (>= (point) savep) (setq savep nil))
+                         (or (smie-indent-calculate) 0)))
+                     0)))
     (if (not (numberp indent))
         ;; If something funny is used (e.g. `noindent'), return it.
         indent
@@ -1362,18 +1411,51 @@
           (save-excursion (indent-line-to indent))
         (indent-line-to indent)))))
 
-(defun smie-indent-debug ()
-  "Show the rules used to compute indentation of current line."
-  (interactive)
-  (let ((smie-indent-debug-log '()))
-    (smie-indent-calculate)
-    ;; FIXME: please improve!
-    (message "%S" smie-indent-debug-log)))
-
-(defun smie-setup (op-levels indent-rules)
-  (set (make-local-variable 'smie-indent-rules) indent-rules)
-  (set (make-local-variable 'smie-op-levels) op-levels)
-  (set (make-local-variable 'indent-line-function) 'smie-indent-line))
+(defun smie-setup (grammar rules-function &rest keywords)
+  "Setup SMIE navigation and indentation.
+GRAMMAR is a grammar table generated by `smie-prec2->grammar'.
+RULES-FUNCTION is a set of indentation rules for use on `smie-rules-function'.
+KEYWORDS are additional arguments, which can use the following keywords:
+- :forward-token FUN
+- :backward-token FUN"
+  (set (make-local-variable 'smie-rules-function) rules-function)
+  (set (make-local-variable 'smie-grammar) grammar)
+  (set (make-local-variable 'indent-line-function) 'smie-indent-line)
+  (set (make-local-variable 'forward-sexp-function)
+       'smie-forward-sexp-command)
+  (while keywords
+    (let ((k (pop keywords))
+          (v (pop keywords)))
+      (case k
+        (:forward-token
+         (set (make-local-variable 'smie-forward-token-function) v))
+        (:backward-token
+         (set (make-local-variable 'smie-backward-token-function) v))
+        (t (message "smie-setup: ignoring unknown keyword %s" k)))))
+  (let ((ca (cdr (assq :smie-closer-alist grammar))))
+    (when ca
+      (set (make-local-variable 'smie-closer-alist) ca)
+      ;; Only needed for interactive calls to blink-matching-open.
+      (set (make-local-variable 'blink-matching-check-function)
+           #'smie-blink-matching-check)
+      (add-hook 'post-self-insert-hook
+                #'smie-blink-matching-open 'append 'local)
+      (set (make-local-variable 'smie-blink-matching-triggers)
+           (append smie-blink-matching-triggers
+                   ;; Rather than wait for SPC to blink, try to blink as
+                   ;; soon as we type the last char of a block ender.
+                   (let ((closers (sort (mapcar #'cdr smie-closer-alist)
+                                        #'string-lessp))
+                         (triggers ())
+                         closer)
+                     (while (setq closer (pop closers))
+                       (unless (and closers
+                                    ;; FIXME: this eliminates prefixes of other
+                                    ;; closers, but we should probably elimnate
+                                    ;; prefixes of other keywords as well.
+                                    (string-prefix-p closer (car closers)))
+                         (push (aref closer (1- (length closer))) triggers)))
+                     (delete-dups triggers)))))))
 
 
 (provide 'smie)
--- a/lisp/emacs-lisp/timer.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/emacs-lisp/timer.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/emacs-lisp/unsafep.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/emulation/cua-base.el	Mon Nov 08 14:19:54 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/emulation/viper-cmd.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/emulation/viper-cmd.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,7 @@
 ;;; viper-cmd.el --- Vi command support for Viper
 
-;; 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: Michael Kifer <kifer@cs.stonybrook.edu>
 ;; Package: viper
@@ -42,7 +42,7 @@
 (defvar quail-current-str)
 (defvar mark-even-if-inactive)
 (defvar init-message)
-(defvar initial)
+(defvar viper-initial)
 (defvar undo-beg-posn)
 (defvar undo-end-posn)
 
@@ -2065,23 +2065,22 @@
     (funcall hook)
     ))
 
-;; Thie is a temp hook that uses free variables init-message and initial.
+;; This is a temp hook that uses free variables init-message and viper-initial.
 ;; A dirty feature, but it is the simplest way to have it do the right thing.
-;; The INIT-MESSAGE and INITIAL vars come from the scope set by
+;; The INIT-MESSAGE and VIPER-INITIAL vars come from the scope set by
 ;; viper-read-string-with-history
 (defun viper-minibuffer-standard-hook ()
   (if (stringp init-message)
       (viper-tmp-insert-at-eob init-message))
-  (if (stringp initial)
-      (progn
-	;; don't wait if we have unread events or in kbd macro
-	(or unread-command-events
-	    executing-kbd-macro
-	    (sit-for 840))
-	(if (fboundp 'minibuffer-prompt-end)
-	    (delete-region (minibuffer-prompt-end) (point-max))
-	  (erase-buffer))
-	(insert initial))))
+  (when (stringp viper-initial)
+    ;; don't wait if we have unread events or in kbd macro
+    (or unread-command-events
+	executing-kbd-macro
+	(sit-for 840))
+    (if (fboundp 'minibuffer-prompt-end)
+	(delete-region (minibuffer-prompt-end) (point-max))
+      (erase-buffer))
+    (insert viper-initial)))
 
 (defsubst viper-minibuffer-real-start ()
   (if (fboundp 'minibuffer-prompt-end)
@@ -2180,10 +2179,10 @@
 
 ;;; Reading string with history
 
-(defun viper-read-string-with-history (prompt &optional initial
+(defun viper-read-string-with-history (prompt &optional viper-initial
 					      history-var default keymap
 					      init-message)
-  ;; Read string, prompting with PROMPT and inserting the INITIAL
+  ;; Read string, prompting with PROMPT and inserting the VIPER-INITIAL
   ;; value.  Uses HISTORY-VAR.  DEFAULT is the default value to accept if the
   ;; input is an empty string.
   ;; Default value is displayed until the user types something in the
@@ -2206,14 +2205,14 @@
 	temp-msg)
 
     (setq keymap (or keymap minibuffer-local-map)
-	  initial (or initial "")
+	  viper-initial (or viper-initial "")
 	  temp-msg (if default
 		       (format "(default %s) " default)
 		     ""))
 
     (setq viper-incomplete-ex-cmd nil)
     (setq val (read-from-minibuffer prompt
-				    (concat temp-msg initial val padding)
+				    (concat temp-msg viper-initial val padding)
 				    keymap nil history-var))
     (setq minibuffer-setup-hook nil
 	  padding (viper-array-to-string (this-command-keys))
@@ -5093,5 +5092,4 @@
 
 
 
-;; arch-tag: 739a6450-5fda-44d0-88b0-325053d888c2
 ;;; viper-cmd.el ends here
--- a/lisp/emulation/viper-init.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/emulation/viper-init.el	Mon Nov 08 14:19:54 2010 +0900
@@ -784,7 +784,7 @@
 
 ;; These two vars control the interaction of jumps performed by ' and `.
 ;; In this new version, '' doesn't erase the marks set by ``, so one can
-;; use both kinds of jumps interchangeably and without loosing positions
+;; use both kinds of jumps interchangeably and without losing positions
 ;; inside the lines.
 
 ;; Remembers position of the last jump done using ``'.
--- a/lisp/epa-mail.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/epa-mail.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/epg-config.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/erc/ChangeLog	Mon Nov 08 14:19:54 2010 +0900
@@ -1,3 +1,19 @@
+2010-11-05  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* erc-backend.el (erc-coding-system-precedence): New variable.
+	(erc-decode-string-from-target): Use it.
+
+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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/erc/erc-backend.el	Mon Nov 08 14:19:54 2010 +0900
@@ -324,6 +324,13 @@
   :type 'integer
   :group 'erc-server)
 
+(defcustom erc-coding-system-precedence '(utf-8 undecided)
+  "List of coding systems to be preferred when receiving a string from the server.
+This will only be consulted if the coding system in
+`erc-server-coding-system' is `undecided'."
+  :group 'erc-server
+  :type '(repeat coding-system))
+
 (defcustom erc-server-coding-system (if (and (fboundp 'coding-system-p)
                                              (coding-system-p 'undecided)
                                              (coding-system-p 'utf-8))
@@ -334,7 +341,9 @@
 
 If a cons, the encoding system for outgoing text is in the car
 and the decoding system for incoming text is in the cdr. The most
-interesting use for this is to put `undecided' in the cdr.
+interesting use for this is to put `undecided' in the cdr. This
+means that `erc-coding-system-precedence' will be consulted, and the
+first match there will be used.
 
 If a function, it is called with the argument `target' and should
 return a coding system or a cons as described above.
@@ -653,30 +662,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
 
@@ -704,6 +714,14 @@
   (let ((coding (erc-coding-system-for-target target)))
     (when (consp coding)
       (setq coding (cdr coding)))
+    (when (eq coding 'undecided)
+      (let ((codings (detect-coding-string str))
+            (precedence erc-coding-system-precedence))
+        (while (and precedence
+                    (not (memq (car precedence) codings)))
+          (pop precedence))
+        (when precedence
+          (setq coding (car precedence)))))
     (erc-decode-coding-string str coding)))
 
 ;; proposed name, not used by anything yet
@@ -1195,7 +1213,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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/erc/erc-xdcc.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/eshell/em-unix.el	Mon Nov 08 14:19:54 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/eshell/esh-util.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/eshell/esh-util.el	Mon Nov 08 14:19:54 2010 +0900
@@ -536,25 +536,18 @@
       (eshell-read-hosts eshell-hosts-file 'eshell-host-names
 			 'eshell-host-timestamp)))
 
-(unless (fboundp 'line-end-position)
-  (defsubst line-end-position (&optional N)
-    (save-excursion (end-of-line N) (point))))
-
-(unless (fboundp 'line-beginning-position)
-  (defsubst line-beginning-position (&optional N)
-    (save-excursion (beginning-of-line N) (point))))
-
-(unless (fboundp 'subst-char-in-string)
-  (defun subst-char-in-string (fromchar tochar string &optional inplace)
-    "Replace FROMCHAR with TOCHAR in STRING each time it occurs.
+(and (featurep 'xemacs)
+     (not (fboundp 'subst-char-in-string))
+     (defun subst-char-in-string (fromchar tochar string &optional inplace)
+       "Replace FROMCHAR with TOCHAR in STRING each time it occurs.
 Unless optional argument INPLACE is non-nil, return a new string."
-    (let ((i (length string))
-	  (newstr (if inplace string (copy-sequence string))))
-      (while (> i 0)
-	(setq i (1- i))
-	(if (eq (aref newstr i) fromchar)
-	    (aset newstr i tochar)))
-      newstr)))
+       (let ((i (length string))
+	     (newstr (if inplace string (copy-sequence string))))
+	 (while (> i 0)
+	   (setq i (1- i))
+	   (if (eq (aref newstr i) fromchar)
+	       (aset newstr i tochar)))
+	 newstr)))
 
 (defsubst eshell-copy-environment ()
   "Return an unrelated copy of `process-environment'."
@@ -594,8 +587,9 @@
 	  (substring string 0 sublen)
 	string)))
 
-(unless (fboundp 'directory-files-and-attributes)
-  (defun directory-files-and-attributes (directory &optional full match nosort id-format)
+(and (featurep 'xemacs)
+     (not (fboundp 'directory-files-and-attributes))
+     (defun directory-files-and-attributes (directory &optional full match nosort id-format)
     "Return a list of names of files and their attributes in DIRECTORY.
 There are three optional arguments:
 If FULL is non-nil, return absolute file names.  Otherwise return names
@@ -607,7 +601,7 @@
       (mapcar
        (function
 	(lambda (file)
-         (cons file (eshell-file-attributes (expand-file-name file directory)))))
+	  (cons file (eshell-file-attributes (expand-file-name file directory)))))
        (directory-files directory full match nosort)))))
 
 (defvar ange-cache)
@@ -802,5 +796,4 @@
 
 (provide 'esh-util)
 
-;; arch-tag: 70159778-5c7a-480a-bae4-3ad332fca19d
 ;;; esh-util.el ends here
--- a/lisp/face-remap.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/face-remap.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/facemenu.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/faces.el	Mon Nov 08 14:19:54 2010 +0900
@@ -30,7 +30,7 @@
 (eval-when-compile
   (require 'cl))
 
-(declare-function xw-defined-colors "term/x-win" (&optional frame))
+(declare-function xw-defined-colors "term/common-win" (&optional frame))
 
 (defvar help-xref-stack-item)
 
@@ -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)))))))))
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -1968,7 +1957,7 @@
 				     (list (cons 'cursor-color fg)))))))
 
 (declare-function x-create-frame "xfns.c" (parms))
-(declare-function x-setup-function-keys "term/x-win" (frame))
+(declare-function x-setup-function-keys "term/common-win" (frame))
 
 (defun x-create-frame-with-faces (&optional parameters)
   "Create and return a frame with frame parameters PARAMETERS.
@@ -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"
@@ -2490,6 +2482,14 @@
 (defface help-argument-name '((((supports :slant italic)) :inherit italic))
   "Face to highlight argument names in *Help* buffers."
   :group 'help)
+
+(defface glyphless-char
+  '((((type tty)) :inherit underline)
+    (t :height 0.6))
+  "Face for displaying non-graphic characters (e.g. U+202A (LRE)).
+It is used for characters of no fonts too."
+  :version "24.1"
+  :group 'basic-faces)
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Manipulating font names.
@@ -2578,5 +2578,4 @@
 
 (provide 'faces)
 
-;; arch-tag: 19a4759f-2963-445f-b004-425b9aadd7d6
 ;;; faces.el ends here
--- a/lisp/files.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/files.el	Mon Nov 08 14:19:54 2010 +0900
@@ -188,32 +188,6 @@
   "Non-nil if visited file was read-only when visited.")
 (make-variable-buffer-local 'buffer-file-read-only)
 
-(defcustom temporary-file-directory
-  (file-name-as-directory
-   ;; FIXME ? Should there be Ftemporary_file_directory to do the
-   ;; following more robustly (cf set_local_socket in emacsclient.c).
-   ;; It could be used elsewhere, eg Fcall_process_region, server-socket-dir.
-   ;; See bug#7135.
-   (cond ((memq system-type '(ms-dos windows-nt))
-	  (or (getenv "TEMP") (getenv "TMPDIR") (getenv "TMP") "c:/temp"))
-	 ((eq system-type 'darwin)
-	  (or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP")
-	      (let ((tmp (ignore-errors (shell-command-to-string ; bug#7135
-					 "getconf DARWIN_USER_TEMP_DIR"))))
-		(and (stringp tmp)
-		     (setq tmp (replace-regexp-in-string "\n\\'" "" tmp))
-		     ;; This handles "getconf: Unrecognized variable..."
-		     (file-directory-p tmp)
-		     tmp))
-	      "/tmp"))
-	 (t
-	  (or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP") "/tmp"))))
-  "The directory for writing temporary files."
-  :group 'files
-  ;; Darwin section added 24.1, does not seem worth :version bump.
-  :initialize 'custom-initialize-delay
-  :type 'directory)
-
 (defcustom small-temporary-file-directory
   (if (eq system-type 'ms-dos) (getenv "TMPDIR"))
   "The directory for writing small temporary files.
@@ -801,9 +775,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))))
@@ -6469,5 +6444,4 @@
 (define-key ctl-x-5-map "r" 'find-file-read-only-other-frame)
 (define-key ctl-x-5-map "\C-o" 'display-buffer-other-frame)
 
-;; arch-tag: bc68d3ea-19ca-468b-aac6-3a4a7766101f
 ;;; files.el ends here
--- a/lisp/finder.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/finder.el	Mon Nov 08 14:19:54 2010 +0900
@@ -198,7 +198,8 @@
 	      (setq summary  (lm-synopsis)
 		    keywords (mapcar 'intern (lm-keywords-list))
 		    package  (or package-override
-				 (intern-soft (lm-header "package"))
+				 (let ((str (lm-header "package")))
+				   (if str (intern str)))
 				 base-name)
 		    version  (lm-header "version")))
 	    (when summary
--- a/lisp/frame.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/frame.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/ChangeLog	Mon Nov 08 14:19:54 2010 +0900
@@ -1,13 +1,850 @@
+2010-11-07  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* gnus-start.el (gnus-get-unread-articles): Ignore totally non-existent
+	methods.
+	(gnus-read-active-file): Ditto.
+
+	* gnus-group.el (gnus-group-read-ephemeral-group): Remove superfluous
+	": " from the prompt.
+	(gnus-group-make-group): Ditto.
+
+2010-11-07  Glenn Morris  <rgm@gnu.org>
+
+	* gnus-bookmark.el (gnus-bookmark-bmenu-show-infos)
+	(gnus-bookmark-kill-line): Use point-at-eol.
+
+2010-11-07  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* gnus-gravatar.el (gnus-gravatar-transform-address): No need to skip
+	asterisks in From header.
+
+2010-11-06  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* gnus-ems.el (gnus-put-image): Use a blank text as the insertion
+	string to avoid making the From headers syntactically invalid.
+
+	* message.el (message-send-mail): Don't insert courtesy messages if the
+	message already has List-Post and List-ID messages.
+
+2010-11-06  Glenn Morris  <rgm@gnu.org>
+
+	* gnus-art.el (gnus-treat-article): Give dynamic local variables
+	`condition', `type', `length' a prefix.
+	(gnus-treat-predicate): Update for above name changes.
+
+2010-11-06  Andrew Cohen  <cohen@andy.bu.edu>
+
+	* nnir.el (gnus-summary-nnir-goto-thread): Remove function and
+	binding.  Handled by `gnus-summary-refer-thread' instead.
+	(nnir-warp-to-article): New backend function.
+
+	* nnimap.el (nnimap-request-thread): Force dependency updating.
+
+	* gnus-sum.el (gnus-fetch-headers): Allow more arguments.
+	(gnus-summary-refer-thread): Rework to improve thread-referral.
+
+	* gnus-int.el (gnus-warp-to-article): New function.
+
+	* gnus-sum.el (gnus-summary-article-map): Bind it.
+
+2010-11-04  Andrew Cohen  <cohen@andy.bu.edu>
+
+	* nnir.el (gnus-summary-nnir-goto-thread): Limit work done by
+	gnus-summary-refer-thread.
+
+	* gnus-sum.el (gnus-build-all-threads): Force updating of dependency
+	headers.
+	(gnus-summary-limit-include-thread): Prevent articles in thread from
+	being cut in gnus-cut-threads.
+	(gnus-summary-refer-thread): Limit retrieved headers to those in
+	thread.
+
+2010-11-04  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* message.el (message-send-mail): Use the value of
+	message-courtesy-message from the message buffer.
+
+	* gnus-html.el (gnus-html-browse-url): Implement mailto: URLs.
+
+	* shr.el (shr-browse-url): Implement mailto: URLs.
+
+	* gnus-sum.el (gnus-summary-show-article): Take `t' as the arg to mean
+	"raw".
+
+	* nnimap.el (nnimap-find-article-by-message-id): Don't EXAMINE a group
+	if it's already selected.
+
+	* mm-decode.el (mm-save-part): Put the entire path in the `M-n' slot.
+
+2010-11-04  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* shr.el (shr-tag-img): Use string-width and truncate-string-to-width
+	to measure the length and truncate alt text.
+
+2010-11-03  Glenn Morris  <rgm@gnu.org>
+
+	* nndiary.el (nndiary-generate-nov-databases-1)
+	(nndiary-generate-active-info): Rename dynamic variable `files' to
+	something less generic.
+
+2010-11-03  Andrew Cohen  <cohen@andy.bu.edu>
+
+	* nnir.el (nnir-request-move-article): Call the underlying backend to
+	move articles from nnir.
+
+2010-11-02  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* gnus-cite.el (gnus-article-natural-long-line-p): Remove.
+
+2010-11-02  Julien Danjou  <julien@danjou.info>
+
+	* nnir.el: Remove wais support.
+
+2010-11-02  Glenn Morris  <rgm@gnu.org>
+
+	* gnus-html.el: Reorder requirements to quieten compiler.
+
+2010-11-02  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* gnus-cite.el (gnus-article-fill-cited-article): Make fill work
+	properly for XEmacs as well.
+	(gnus-article-fill-cited-article, gnus-article-foldable-buffer)
+	(gnus-article-natural-long-line-p): Use window-width rather than
+	frame-width.
+
+2010-11-01  Andrew Cohen  <cohen@andy.bu.edu>
+
+	* nnir.el (nnir-run-gmane): Inhibit demon.  Return nil if no messages.
+	(nnir-read-parms): Don't modify query.
+	(nnir-run-query): Add ability to search topic on current line.
+	(nnir-get-active): Clean up.
+
+2010-11-01  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* gnus-cite.el (gnus-article-foldable-buffer): Protect against
+	degenerate articles.
+
+	* gnus-sum.el (gnus-print-buffer): Rewrite to use with-temp-buffer.
+	(gnus-print-buffer): Just print the buffer as is, without any copying
+	to a buffer and then re-highlighting.
+
+	* nnimap.el (nnimap-request-group): Store the new updated info.
+	(nnimap-request-group): Select the group when we don't know whether it
+	exists or not.
+
+	* gnus-start.el (gnus-ask-server-for-new-groups): Return the new
+	groups.
+
+	* gnus-group.el (gnus-group-find-new-groups): Display all the new
+	groups.
+
+	* gnus-start.el (gnus-find-new-newsgroups): Return the list of new
+	groups.
+
+	* gnus-cite.el (gnus-article-fill-cited-article): Minimize the
+	long-lines case by only filling the long lines.
+
+	* nnimap.el (nnimap-parse-line): Don't bug out oddly formed replies
+	(bug #7311).
+
+2010-11-01  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* shr.el: No need to declare `declare-function' since shr.el is for
+	only Emacsen that provide `libxml-parse-html-region'.
+
+2010-11-01  Glenn Morris  <rgm@gnu.org>
+
+	* mm-util.el (gnus-completing-read): Autoload.
+	(mm-read-coding-system): Simplify Emacs definition.
+
+	* nnmail.el (gnus-activate-group):
+	* nnimap.el (gnutls-negotiate):
+	* nntp.el (netrc-parse): Fix declarations.
+
+2010-11-01  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* gnus-util.el (gnus-string-match-p): New function, that is an alias to
+	string-match-p in Emacs >=23.
+
+	* gnus-msg.el (gnus-configure-posting-styles)
+	* nnir.el (nnir-run-gmane): Use gnus-string-match-p.
+
+2010-11-01  Glenn Morris  <rgm@gnu.org>
+
+	* nnir.el (declare-function): Add compat stub.
+	(mm-url-insert, mm-url-encode-www-form-urlencoded): Declare.
+	(nnir-run-gmane): Require 'mm-url.
+
+	* mm-util.el (mm-string-to-multibyte): Simplify.
+
+	* shr.el (declare-function): Add compat stub.
+	(url-cache-create-filename): Declare.
+	(mm-disable-multibyte, widget-convert-button): Autoload.
+
+	* smime.el (ldap-search): Declare.
+	(smime-cert-by-ldap-1): Require ldap on Emacs.
+
+	* nnimap.el: Require nnmail, and gnus-sum when compiling.
+	(nnimap-keepalive): Use gnus-float-time.
+
+	* mail-source.el (nnheader-message, gnus-float-time): Autoload.
+	(mail-source-delete-crash-box): Use gnus-float-time.
+
+	* gnus-dired.el (gnus-completing-read): Autoload.
+
+	* mm-view.el (gnus-rescale-image): Autoload.
+
+	* mm-decode.el (gnus-completing-read, gnus-blocked-images): Autoload.
+
+	* gnus.el (gnus-sloppily-equal-method-parameters): Move defn before use.
+
+	* sieve-manage.el: Require 'cl when compiling.
+
+	* gnus-util.el (iswitchb-read-buffer): Declare rather than autoload.
+	(gnus-iswitchb-completing-read): Require iswitchb.
+	(gnus-select-frame-set-input-focus): Silence compiler.
+
+2010-10-31  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* message.el (message-subject-trailing-was-query): Change default to t,
+	since I think that's what most people want.
+
+	* nnimap.el (nnimap-request-accept-article): Erase buffer before
+	appending for easier debugging.
+	(nnimap-wait-for-connection): Take a regexp.
+	(nnimap-request-accept-article): Wait for the continuation line before
+	sending anything unless we're streaming.
+
+	* gnus-art.el (gnus-treat-article): Only inhibit body washing, and
+	leave the header washing to take place.
+
+2010-10-31  Daniel Dehennin  <daniel.dehennin@baby-gnu.org>
+
+	* gnus-msg.el (gnus-configure-posting-styles): Permit the use of
+	regular expression match and replace in posting styles.
+
+2010-10-31  Andrew Cohen  <cohen@andy.bu.edu>
+
+	* nnir.el (gnus-group-make-nnir-group,nnir-run-query): Allow searching
+	an entire server.
+	(nnir-get-active): New function.
+	(nnir-run-imap): Use it.
+	(nnir-run-gmane): Who knew, gmane search returns an article score!
+
+	* gnus-srvr.el (gnus-server-mode-map): add binding "G" to search the
+	server on the current line with nnir.
+
+2010-10-31  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* gnus-cite.el (gnus-article-foldable-buffer): Refactor out.
+	(gnus-article-foldable-buffer): Don't fold regions that have a ragged
+	left edge.
+	(gnus-article-foldable-buffer): Skip past the prefix when determining
+	raggedness.
+
+	* gnus-sum.el (gnus-summary-show-article): Add `C-u C-u g' for showing
+	the raw article, and change `C-u g' to show the article without doing
+	treatments.
+
+	* gnus-art.el (gnus-mime-display-alternative): Actually pass the type
+	on to `gnus-treat-article'.
+	(gnus-inhibit-article-treatments): New variable.
+
+	* gnus.el: Autoload gnus-article-fill-cited-long-lines.
+
+	* gnus-art.el (gnus-treatment-function-alist): Have
+	gnus-treat-fill-long-lines point to gnus-article-fill-cited-long-lines.
+	(gnus-treat-fill-long-lines): Change default to fill all text/plain
+	sections.
+
+	* gnus-cite.el (gnus-article-fill-cited-article): Remove unused `force'
+	parameter.
+	(gnus-article-fill-cited-long-lines): New function.
+	(gnus-article-fill-cited-article): Allow filling only long sections.
+
+	* shr.el (shr-find-fill-point): Don't break lines between punctuation
+	and non-punctuation (like after the apostrophe in "'We").
+
+	* gnus-sum.el (gnus-summary-select-article): Make sure
+	gnus-original-article-buffer is alive.
+
+	* nndoc.el (nndoc-dissect-buffer): Reverse the order of the articles to
+	reflect the order they're in in the digest.
+
+	* gnus.el (gnus-group-startup-message): Move point to the start of the
+	buffer.
+
+	* nnimap.el (nnimap-capability): New function.
+	(nnimap-open-connection): Only send AUTHENTICATE PLAIN if LOGINDISABLED
+	is set.
+
+2010-10-31  David Engster  <dengste@eml.cc>
+
+	* nnmairix.el (nnmairix-get-valid-servers): Return list of strings to
+	conform with changes to gnus-completing-read.
+
+2010-10-30  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* shr.el (shr-tag-img): Output "*" instead of "[img]".
+
+2010-10-30  Andrew Cohen  <cohen@andy.bu.edu>
+
+	* nnir.el move defvar, defcustom around to keep file organized and keep
+	byte-compiler quiet.
+	(nnir-read-parms): accept search-engine as arg.
+	(nnir-run-query): pass search-engine as arg.
+	(nnir-search-engine): remove.
+
+2010-10-30  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* shr.el (shr-generic): The text nodes should be text, not :text.
+
+	* nnir.el (nnir-search-engine): Ressurect variable, since it's used
+	later in the file.
+
+2010-10-30  Andrew Cohen  <cohen@andy.bu.edu>
+
+	* nnir.el: general clean up. allow searching with multiple
+	engines. allow separate extra-parameters for each engine. batch queries
+	when possible.
+	(nnir-imap-default-search-key,nnir-method-default-engines): add
+	customize interface.
+	(nnir-run-gmane): new engine.
+	(nnir-engines): use it. qualify all prompts with engine name.
+	(nnir-search-engine): remove global variable.
+	(nnir-run-hyrex): restore for now.
+	(nnir-extra-parms,nnir-search-history): new variables.
+	(gnus-group-make-nnir-group): use them.
+	(nnir-group-server): remove in favor of gnus-group-server.
+	(nnir-request-group): avoid searching twice.
+	(nnir-sort-groups-by-server): new function.
+
+2010-10-30  Julien Danjou  <julien@danjou.info>
+
+	* gnus-group.el: Remove gnus-group-fetch-control.
+
+	* gnus-start.el (gnus-find-new-newsgroups): Remove
+	gnus-check-first-time-used.
+
+	* gnus.el: Remove gnus-backup-default-subscribed-newsgroups.
+
+2010-10-30  Knut Anders Hatlen  <kahatlen@gmail.com>  (tiny change)
+
+	* nnimap.el (nnimap-update-info): Allow 'ticked and other flags to be
+	set on groups that don't have \* permanentflags.
+
+2010-10-30  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* shr.el (shr-tag-span): Drop colorisation of regions since we don't
+	control the background color.
+	(shr-tag-img): Ignore very small web bug type images.
+	(shr-put-image): Add help-echo alt texts to the images.
+	(shr-tag-video): Show the video poster image.
+
+2010-10-29  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* shr.el (shr-table-depth): New variable.
+	(shr-tag-table-1): Only insert the images after the top-level table.
+
+	* nnimap.el (nnimap-split-incoming-mail): Fix typo.
+
+	* gnus-util.el (gnus-list-memq-of-list): New function.
+
+	* nnimap.el (nnimap-split-incoming-mail): Note that the INBOX has been
+	selected.
+	(nnimap-unsplittable-articles): New slot.
+	(nnimap-new-articles): Use it.
+
+2010-10-29  Stephen Berman  <stephen.berman@gmx.net>  (tiny change)
+
+	* gnus-group.el (gnus-group-get-new-news-this-group): Don't have point
+	move to the previous line on `M-g'.
+
+2010-10-29  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* gnus-msg.el (gnus-inews-do-gcc): Don't have the backends do the slow
+	*-request-group, which seems unnecessary.
+
+	* nnimap.el (nnimap-quote-specials): Function copied over from
+	imap.el.
+	(nnimap-open-connection): Use AUTHENTICATE PLAIN on servers that say
+	they support that.  Suggested by Tom Regner.
+
+2010-10-29  Julien Danjou  <julien@danjou.info>
+
+	* gnus-sum.el (gnus-summary-delete-marked-as-read): Remove obsolete
+	defalias.
+	(gnus-summary-delete-marked-with): Remove obsolete defalias.
+
+	* gnus.el: Remove `gnus-nntp-service' variable.
+	(gnus-secondary-servers): Make obsolete.
+	(gnus-nntp-server): Make obsolete.
+
+	* gnus-start.el (gnus-1): Remove x-splash calls.
+
+	* gnus-ems.el (gnus-x-splash): Remove.
+
+	* gnus.el (gnus-group-startup-message): Simplify/update code.
+
+	* gnus-group.el (gnus-group-make-tool-bar): Check for display graphic
+	capability before doing anything.
+	(gnus-group-insert-group-line): Remove useless
+	gnus-group-remove-excess-properties.
+
+2010-10-29  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* gnus-art.el (gnus-article-goto-part): Work for article narrowed by ^L.
+
+2010-10-28  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* gnus-sum.el (gnus-summary-rescan-group): Try to restore the window
+	config after reselecting.
+
+2010-10-28  Julien Danjou  <julien@danjou.info>
+
+	* shr.el (shr-put-image): Use point even if only inserting text.
+	(shr-put-image): Save excursion when inserting alt text on non-graphic
+	display, so the behaviour is the same when we are on a graphic display.
+
+	* nnir.el (nnir-run-swish-e): Remove hyrex support.
+
+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.
 
-	* gnus-art.el, gnus-cache.el, gnus-fun.el, gnus-group.el,
-	gnus-picon.el, gnus-spec.el, gnus-sum.el, gnus-util.el, gnus.el,
-	mail-source.el, message.el, mm-bodies.el, mm-decode.el, mm-extern.el,
-	mm-util.el, mm-view.el, mml-smime.el, mml.el, mml1991.el, mml2015.el,
-	nnfolder.el, nnheader.el, nnmail.el, nnmaildir.el, nnrss.el, nntp.el,
-	rfc1843.el, sieve-manage.el, smime.el, spam.el:
+	* gnus-art.el, gnus-cache.el, gnus-fun.el, gnus-group.el:
+	* gnus-picon.el, gnus-spec.el, gnus-sum.el, gnus-util.el, gnus.el:
+	* mail-source.el, message.el, mm-bodies.el, mm-decode.el, mm-extern.el:
+	* mm-util.el, mm-view.el, mml-smime.el, mml.el, mml1991.el, mml2015.el:
+	* nnfolder.el, nnheader.el, nnmail.el, nnmaildir.el, nnrss.el, nntp.el:
+	* rfc1843.el, sieve-manage.el, smime.el, spam.el:
 	Fix comment for declare-function.
 
 2010-10-11  Lars Magne Ingebrigtsen  <larsi@gnus.org>
@@ -907,7 +1744,7 @@
 
 2010-09-27  David Engster  <dengste@eml.cc>
 
-	* nnmairix.el: (nnmairix-replace-group-and-numbers): Deal with NOV as
+	* nnmairix.el (nnmairix-replace-group-and-numbers): Deal with NOV as
 	well as HEADERS.
 	(nnmairix-retrieve-headers): Provide new argument for the above.
 
@@ -1285,7 +2122,7 @@
 	(nnimap-make-process-buffer): Store all the process buffers.
 	(nnimap-keepalive): New function.
 
-	* starttls.el: (starttls-open-stream): Add autoload cookie.
+	* starttls.el (starttls-open-stream): Add autoload cookie.
 
 2010-09-24  Michael Welsh Duggan  <md5i@md5i.com>  (tiny change)
 
--- a/lisp/gnus/ChangeLog.2	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/ChangeLog.2	Mon Nov 08 14:19:54 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.
@@ -16434,7 +16433,7 @@
 2001-01-09  Didier Verna  <didier@xemacs.org>
 
 	* gnus-agent.el: Moved some XEmacs specific hook add-ons from
-	`gnus-xmas-[re]define' to avoid loosing user custom settings.
+	`gnus-xmas-[re]define' to avoid losing user custom settings.
 	* gnus-art.el: Ditto.
 	* gnus-group.el: Ditto.
 	* gnus-salt.el: Ditto.
--- a/lisp/gnus/ecomplete.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/ecomplete.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/gnus-agent.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/gnus-art.el	Mon Nov 08 14:19:54 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
@@ -1590,7 +1590,7 @@
   :link '(custom-manual "(gnus)Customizing Articles")
   :type gnus-article-treat-custom)
 
-(defcustom gnus-treat-fill-long-lines nil
+(defcustom gnus-treat-fill-long-lines '(typep "text/plain")
   "Fill long lines.
 Valid values are nil, t, `head', `first', `last', an integer or a
 predicate.  See Info node `(gnus)Customizing Articles'."
@@ -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)
@@ -1664,7 +1664,7 @@
     (gnus-treat-highlight-signature gnus-article-highlight-signature)
     (gnus-treat-buttonize gnus-article-add-buttons)
     (gnus-treat-fill-article gnus-article-fill-cited-article)
-    (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
+    (gnus-treat-fill-long-lines gnus-article-fill-cited-long-lines)
     (gnus-treat-strip-cr gnus-article-remove-cr)
     (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
     (gnus-treat-date-ut gnus-article-date-ut)
@@ -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,41 @@
 
 (defun gnus-article-goto-part (n)
   "Go to MIME part N."
-  (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
+  (when gnus-break-pages
+    (widen))
+  (prog1
+      (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))))
+    (when gnus-break-pages
+      (gnus-narrow-to-page))))
 
 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
   (let ((gnus-tmp-name
@@ -5758,7 +5704,7 @@
 	  (save-restriction
 	    (article-goto-body)
 	    (narrow-to-region (point) (point-max))
-	    (gnus-treat-article nil 1 1)
+	    (gnus-treat-article nil 1 1 "text/plain")
 	    (widen)))
 	(unless ihandles
 	  ;; Highlight the headers.
@@ -6046,7 +5992,7 @@
 		  (gnus-treat-article
 		   nil (length gnus-article-mime-handle-alist)
 		   (gnus-article-mime-total-parts)
-		   (mm-handle-media-type handle))))))
+		   (mm-handle-media-type preferred))))))
 	  (goto-char (point-max))
 	  (setcdr begend (point-marker)))))
     (when ibegend
@@ -6887,6 +6833,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
 ;;;
@@ -8297,16 +8255,19 @@
 ;;; Treatment top-level handling.
 ;;;
 
-(defun gnus-treat-article (condition &optional part-number total-parts type)
-  (let ((length (- (point-max) (point-min)))
+(defvar gnus-inhibit-article-treatments nil)
+
+(defun gnus-treat-article (gnus-treat-condition
+			   &optional part-number total-parts gnus-treat-type)
+  (let ((gnus-treat-length (- (point-max) (point-min)))
 	(alist gnus-treatment-function-alist)
 	(article-goto-body-goes-to-point-min-p t)
 	(treated-type
-	 (or (not type)
+	 (or (not gnus-treat-type)
 	     (catch 'found
 	       (let ((list gnus-article-treat-types))
 		 (while list
-		   (when (string-match (pop list) type)
+		   (when (string-match (pop list) gnus-treat-type)
 		     (throw 'found t)))))))
 	(highlightp (gnus-visual-p 'article-highlight 'highlight))
 	val elem)
@@ -8319,6 +8280,8 @@
 	      (symbol-value (car elem))))
       (when (and (or (consp val)
 		     treated-type)
+		 (or (not gnus-inhibit-article-treatments)
+		     (eq gnus-treat-condition 'head))
 		 (gnus-treat-predicate val)
 		 (or (not (get (car elem) 'highlight))
 		     highlightp))
@@ -8328,16 +8291,16 @@
 ;; Dynamic variables.
 (defvar part-number)
 (defvar total-parts)
-(defvar type)
-(defvar condition)
-(defvar length)
+(defvar gnus-treat-type)
+(defvar gnus-treat-condition)
+(defvar gnus-treat-length)
 
 (defun gnus-treat-predicate (val)
   (cond
    ((null val)
     nil)
-   (condition
-    (eq condition val))
+   (gnus-treat-condition
+    (eq gnus-treat-condition val))
    ((and (listp val)
 	 (stringp (car val)))
     (apply 'gnus-or (mapcar `(lambda (s)
@@ -8353,7 +8316,7 @@
        ((eq pred 'not)
 	(not (gnus-treat-predicate (car val))))
        ((eq pred 'typep)
-	(equal (car val) type))
+	(equal (car val) gnus-treat-type))
        (t
 	(error "%S is not a valid predicate" pred)))))
    ((eq val t)
@@ -8365,7 +8328,7 @@
    ((eq val 'last)
     (eq part-number total-parts))
    ((numberp val)
-    (< length val))
+    (< gnus-treat-length val))
    (t
     (error "%S is not a valid value" val))))
 
--- a/lisp/gnus/gnus-bookmark.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/gnus-bookmark.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,6 +1,7 @@
 ;;; gnus-bookmark.el --- Bookmarks in Gnus
 
-;; Copyright (C) 2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
+;; Copyright (C) 2006, 2007, 2008, 2009, 2010
+;;   Free Software Foundation, Inc.
 
 ;; Author: Bastien Guerry <bzg AT altern DOT org>
 ;; Keywords: news
@@ -538,7 +539,7 @@
             (let ((bmrk (gnus-bookmark-bmenu-bookmark)))
               (setq gnus-bookmark-bmenu-hidden-bookmarks
                     (cons bmrk gnus-bookmark-bmenu-hidden-bookmarks))
-	      (let ((start (save-excursion (end-of-line) (point))))
+	      (let ((start (point-at-eol)))
 		(move-to-column gnus-bookmark-bmenu-file-column t)
 		;; Strip off `mouse-face' from the white spaces region.
 		(if (gnus-bookmark-mouse-available-p)
@@ -572,10 +573,9 @@
   "Kill from point to end of line.
 If optional arg NEWLINE-TOO is non-nil, delete the newline too.
 Does not affect the kill ring."
-  (let ((eol (save-excursion (end-of-line) (point))))
-    (delete-region (point) eol)
-    (if (and newline-too (looking-at "\n"))
-        (delete-char 1))))
+  (delete-region (point) (point-at-eol))
+  (if (and newline-too (looking-at "\n"))
+      (delete-char 1)))
 
 (defun gnus-bookmark-get-details (bmk-name details-list)
   "Get details for a Gnus BMK-NAME depending on DETAILS-LIST."
--- a/lisp/gnus/gnus-cite.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/gnus-cite.el	Mon Nov 08 14:19:54 2010 +0900
@@ -516,10 +516,15 @@
 	    (setq m (cdr m))))
 	marks))))
 
-(defun gnus-article-fill-cited-article (&optional force width)
+(defun gnus-article-fill-cited-long-lines ()
+  (gnus-article-fill-cited-article nil t))
+
+(defun gnus-article-fill-cited-article (&optional width long-lines)
   "Do word wrapping in the current article.
-If WIDTH (the numerical prefix), use that text width when filling."
-  (interactive (list t current-prefix-arg))
+If WIDTH (the numerical prefix), use that text width when
+filling.  If LONG-LINES, only fill sections that have lines
+longer than the frame width."
+  (interactive "P")
   (with-current-buffer gnus-article-buffer
     (let ((buffer-read-only nil)
 	  (inhibit-point-motion-hooks t)
@@ -535,8 +540,24 @@
 		(fill-prefix
 		 (if (string= (cdar marks) "") ""
 		   (concat (cdar marks) " ")))
+		(do-fill (not long-lines))
 		use-hard-newlines)
-	    (fill-region (point-min) (point-max)))
+	    (unless do-fill
+	      (setq do-fill (gnus-article-foldable-buffer (cdar marks))))
+	    ;; Note: the XEmacs version of `fill-region' inserts a newline
+	    ;; unless the region ends with a newline.
+	    (when do-fill
+	      (if (not long-lines)
+		  (fill-region (point-min) (point-max))
+		(goto-char (point-min))
+		(while (not (eobp))
+		  (end-of-line)
+		  (when (prog1
+			    (> (current-column) (window-width))
+			  (forward-line 1))
+		    (save-restriction
+		      (narrow-to-region (line-beginning-position 0) (point))
+		      (fill-region (point-min) (point-max))))))))
 	  (set-marker (caar marks) nil)
 	  (setq marks (cdr marks)))
 	(when marks
@@ -548,23 +569,28 @@
 	      gnus-cite-loose-attribution-alist nil
 	      gnus-cite-article nil)))))
 
-(defun gnus-article-natural-long-line-p ()
-  "Return true if the current line is long, and it's natural text."
-  (save-excursion
-    (beginning-of-line)
-    (and
-     ;; The line is long.
-     (> (- (line-end-position) (line-beginning-position))
-	(frame-width))
-     ;; It doesn't start with spaces.
-     (not (looking-at "    "))
-     ;; Not cited text.
-     (let ((line-number (1+ (count-lines (point-min) (point))))
-	   citep)
-       (dolist (elem gnus-cite-prefix-alist)
-	 (when (member line-number (cdr elem))
-	   (setq citep t)))
-       (not citep)))))
+(defun gnus-article-foldable-buffer (prefix)
+  (let ((do-fill nil)
+	columns)
+    (goto-char (point-min))
+    (while (not (eobp))
+      (unless (> (length prefix) (- (point-max) (point)))
+	(forward-char (length prefix)))
+      (skip-chars-forward " \t")
+      (unless (eolp)
+	(let ((elem (assq (current-column) columns)))
+	  (unless elem
+	    (setq elem (cons (current-column) 0))
+	    (push elem columns))
+	  (setcdr elem (1+ (cdr elem)))))
+      (end-of-line)
+      (when (> (current-column) (window-width))
+	(setq do-fill t))
+      (forward-line 1))
+    (and do-fill
+	 ;; We know know that there are long lines here, but does this look
+	 ;; like code?  Check for ragged edges on the left.
+	 (< (length columns) 3))))
 
 (defun gnus-article-hide-citation (&optional arg force)
   "Toggle hiding of all cited text except attribution lines.
--- a/lisp/gnus/gnus-delay.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/gnus-delay.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/gnus-demon.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/gnus-diary.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/gnus-dired.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,7 @@
 ;;; gnus-dired.el --- utility functions where gnus and dired meet
 
-;; Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005,
+;;   2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Authors: Benjamin Rutt <brutt@bloomington.in.us>,
 ;;          Shenghuo Zhu <zsh@cs.rochester.edu>
@@ -122,6 +122,8 @@
 	    (push (buffer-name buffer) buffers))))
       (nreverse buffers))))
 
+(autoload 'gnus-completing-read "gnus-util")
+
 ;; Method to attach files to a mail composition.
 (defun gnus-dired-attach (files-to-attach)
   "Attach dired's marked files to a gnus message composition.
@@ -133,7 +135,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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/gnus-draft.el	Mon Nov 08 14:19:54 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-ems.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/gnus-ems.el	Mon Nov 08 14:19:54 2010 +0900
@@ -162,102 +162,6 @@
 (autoload 'gnus-alive-p "gnus-util")
 (autoload 'mm-disable-multibyte "mm-util")
 
-(defun gnus-x-splash ()
-  "Show a splash screen using a pixmap in the current buffer."
-  (interactive)
-  (unless window-system
-    (error "`gnus-x-splash' requires running on the window system"))
-  (switch-to-buffer (gnus-get-buffer-create (if (or (gnus-alive-p)
-						    (interactive-p))
-						"*gnus-x-splash*"
-					      gnus-group-buffer)))
-  (let ((inhibit-read-only t)
-	(file (nnheader-find-etc-directory "images/gnus/x-splash" t))
-	pixmap fcw fch width height fringes sbars left yoffset top ls)
-    (erase-buffer)
-    (sit-for 0) ;; Necessary for measuring the window size correctly.
-    (when (and file
-	       (ignore-errors
-		(let ((coding-system-for-read 'raw-text))
-		  (with-temp-buffer
-                    (mm-disable-multibyte)
-		    (insert-file-contents file)
-		    (goto-char (point-min))
-		    (setq pixmap (read (current-buffer)))))))
-      (setq fcw (float (frame-char-width))
-	    fch (float (frame-char-height))
-	    width (/ (car pixmap) fcw)
-	    height (/ (cadr pixmap) fch)
-	    fringes (if (fboundp 'window-fringes)
-			(eval '(window-fringes))
-		      '(10 11 nil))
-	    sbars (frame-parameter nil 'vertical-scroll-bars))
-      (cond ((eq sbars 'right)
-	     (setq sbars
-		   (cons 0 (/ (or (frame-parameter nil 'scroll-bar-width) 14)
-			      fcw))))
-	    (sbars
-	     (setq sbars
-		   (cons (/ (or (frame-parameter nil 'scroll-bar-width) 14)
-			    fcw)
-			 0)))
-	    (t
-	     (setq sbars '(0 . 0))))
-      (setq left (- (* (round (/ (1- (/ (+ (window-width)
-					   (car sbars) (cdr sbars)
-					   (/ (+ (or (car fringes) 0)
-						 (or (cadr fringes) 0))
-					      fcw))
-					width))
-				 2))
-		       width)
-		    (car sbars)
-		    (/ (or (car fringes) 0) fcw))
-	    yoffset (cadr (window-edges))
-	    top (max 0 (- (* (max (if (and (boundp 'tool-bar-mode)
-					   tool-bar-mode
-					   (not (featurep 'gtk))
-					   (eq (frame-first-window)
-					       (selected-window)))
-				      1 0)
-				  (round (/ (1- (/ (+ (1- (window-height))
-						      (* 2 yoffset))
-						   height))
-					    2)))
-			     height)
-			  yoffset))
-	    ls (/ (or line-spacing 0) fch)
-	    height (max 0 (- height ls)))
-      (cond ((>= (- top ls) 1)
-	     (insert
-	      (propertize
-	       " "
-	       'display `(space :width 0 :ascent 100))
-	      "\n"
-	      (propertize
-	       " "
-	       'display `(space :width 0 :height ,(- top ls 1) :ascent 100))
-	      "\n"))
-	    ((> (- top ls) 0)
-	     (insert
-	      (propertize
-	       " "
-	       'display `(space :width 0 :height ,(- top ls) :ascent 100))
-	      "\n")))
-      (if (and (> width 0) (> left 0))
-	  (insert (propertize
-		   " "
-		   'display `(space :width ,left :height ,height :ascent 0)))
-	(setq width (+ width left)))
-      (when (> width 0)
-	(insert (propertize
-		 " "
-		 'display `(space :width ,width :height ,height :ascent 0)
-		 'face `(gnus-splash :stipple ,pixmap))))
-      (goto-char (if (<= (- top ls) 0) (1- (point)) (point-min)))
-      (redraw-frame (selected-frame))
-      (sit-for 0))))
-
 ;;; Image functions.
 
 (defun gnus-image-type-available-p (type)
@@ -277,7 +181,7 @@
 
 (defun gnus-put-image (glyph &optional string category)
   (let ((point (point)))
-    (insert-image glyph (or string "*"))
+    (insert-image glyph (or string " "))
     (put-text-property point (point) 'gnus-image-category category)
     (unless string
       (put-text-property (1- (point)) (point)
--- a/lisp/gnus/gnus-gravatar.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/gnus-gravatar.el	Mon Nov 08 14:19:54 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,77 @@
              (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 (or force
+		  (not (and gnus-gravatar-too-ugly
+			    (or (string-match gnus-gravatar-too-ugly
+					      (car address))
+				(and (setq name (cdr address))
+				     (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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/gnus-group.el	Mon Nov 08 14:19:54 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
@@ -737,7 +741,6 @@
   "e" gnus-score-edit-all-score)
 
 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
-  "C" gnus-group-fetch-control
   "d" gnus-group-describe-group
   "v" gnus-version)
 
@@ -757,7 +760,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
@@ -804,10 +806,6 @@
        ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
 	,@(if (featurep 'xemacs) nil
 	    '(:help "Display description of the current group"))]
-       ["Fetch control message" gnus-group-fetch-control
-	:active (gnus-group-group-name)
-	,@(if (featurep 'xemacs) nil
-	    '(:help "Display the archived control message for the current group"))]
        ;; Actually one should check, if any of the marked groups gives t for
        ;; (gnus-check-backend-function 'request-expire-articles ...)
        ["Expire articles" gnus-group-expire-articles
@@ -905,6 +903,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]
@@ -1086,8 +1085,7 @@
   (when (and (not (featurep 'xemacs))
 	     (boundp 'tool-bar-mode)
 	     tool-bar-mode
-	     ;; The Gnus 5.10.6 code checked (default-value 'tool-bar-mode).
-	     ;; Why?  --rsteib
+             (display-graphic-p)
 	     (or (not gnus-group-tool-bar-map) force))
     (let* ((load-path
 	    (gmm-image-load-path-for-library "gnus"
@@ -1166,6 +1164,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 +1179,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 +1231,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 +1552,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
@@ -1597,9 +1601,7 @@
     (when (inline (gnus-visual-p 'group-highlight 'highlight))
       (gnus-group-highlight-line gnus-tmp-group beg end))
     (gnus-run-hooks 'gnus-group-update-hook)
-    (forward-line)
-    ;; Allow XEmacs to remove front-sticky text properties.
-    (gnus-group-remove-excess-properties)))
+    (forward-line)))
 
 (defun gnus-group-update-eval-form (group list)
   "Eval `car' of each element of LIST, and return the first that return t.
@@ -1888,7 +1890,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 +2192,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)
@@ -2263,7 +2267,7 @@
    (list
     ;; (gnus-read-group "Group name: ")
     (gnus-group-completing-read)
-    (gnus-read-method "From method: ")))
+    (gnus-read-method "From method")))
   ;; Transform the select method into a unique server.
   (when (stringp method)
     (setq method (gnus-server-to-method method)))
@@ -2424,9 +2428,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"
@@ -2670,7 +2674,7 @@
   (interactive
    (list
     (gnus-read-group "Group name: ")
-    (gnus-read-method "From method: ")))
+    (gnus-read-method "From method")))
 
   (when (stringp method)
     (setq method (or (gnus-server-to-method method) method)))
@@ -3677,7 +3681,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)
@@ -3979,7 +3983,7 @@
   (let* ((groups (gnus-group-process-prefix n))
 	 (ret (if (numberp n) (- n (length groups)) 0))
 	 (beg (unless n
-		(point)))
+		(point-marker)))
 	 group method
 	 (gnus-inhibit-demon t)
 	 ;; Binding this variable will inhibit multiple fetchings
@@ -4010,35 +4014,9 @@
       (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)
-  "Fetch the archived control messages for the current group.
-If given a prefix argument, prompt for a group."
-  (interactive
-   (list (or (when current-prefix-arg
-	       (gnus-group-completing-read))
-	     (gnus-group-group-name)
-	     gnus-newsgroup-name)))
-  (unless group
-    (error "No group name given"))
-  (let ((name (gnus-group-real-name group))
-	hierarchy)
-    (when (string-match "\\(^[^\\.]+\\)\\..*" name)
-      (setq hierarchy (match-string 1 name))
-      (if gnus-group-fetch-control-use-browse-url
-	  (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
-			      hierarchy "/" name ".gz"))
-	(let ((enable-local-variables nil))
-	  (gnus-group-read-ephemeral-group
-	   group
-	   `(nndoc ,group (nndoc-address
-			   ,(find-file-noselect
-			     (concat "/ftp@ftp.isc.org:/usenet/control/"
-				     hierarchy "/" name ".gz")))
-		   (nndoc-article-type mbox)) t nil nil))))))
-
 (defun gnus-group-describe-group (force &optional group)
   "Display a description of the current newsgroup."
   (interactive (list current-prefix-arg (gnus-group-group-name)))
@@ -4208,8 +4186,14 @@
 With 2 C-u's, use most complete method possible to query the server
 for new groups, and subscribe the new groups as zombies."
   (interactive "p")
-  (gnus-find-new-newsgroups (or arg 1))
-  (gnus-group-list-groups))
+  (let ((new-groups (gnus-find-new-newsgroups (or arg 1)))
+	current-group)
+    (gnus-group-list-groups)
+    (setq current-group (gnus-group-group-name))
+    (dolist (group new-groups)
+      (gnus-group-jump-to-group group))
+    (when current-group
+      (gnus-group-jump-to-group current-group))))
 
 (defun gnus-group-edit-global-kill (&optional article group)
   "Edit the global kill file.
--- a/lisp/gnus/gnus-html.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/gnus-html.el	Mon Nov 08 14:19:54 2010 +0900
@@ -29,9 +29,10 @@
 ;;; Code:
 
 (eval-when-compile (require 'cl))
+
+(require 'gnus-art)
 (eval-when-compile (require 'mm-decode))
 
-(require 'gnus-art)
 (require 'mm-url)
 (require 'url)
 (require 'url-cache)
@@ -205,8 +206,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
@@ -349,9 +350,13 @@
   "Browse the image under point."
   (interactive)
   (let ((url (get-text-property (point) 'gnus-string)))
-    (if (not url)
-	(message "No URL at point")
-      (browse-url url))))
+    (cond
+     ((not url)
+      (message "No link under point"))
+     ((string-match "^mailto:" url)
+      (gnus-url-mailto url))
+     (t
+      (browse-url url)))))
 
 (defun gnus-html-schedule-image-fetching (buffer image)
   "Retrieve IMAGE, and place it into BUFFER on arrival."
@@ -491,10 +496,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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/gnus-int.el	Mon Nov 08 14:19:54 2010 +0900
@@ -100,8 +100,6 @@
 	;; Stream is already opened.
 	nil
       ;; Open NNTP server.
-      (unless gnus-nntp-service
-	(setq gnus-nntp-server nil))
       (when confirm
 	;; Read server name with completion.
 	(setq gnus-nntp-server
@@ -504,6 +502,23 @@
 	     article (gnus-group-real-name group)
 	     (nth 1 gnus-command-method) buffer)))
 
+(defun gnus-request-thread (id)
+  "Request the headers in 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-warp-to-article ()
+  "Warps from an article in a virtual group to the article in its
+real group. Does nothing on a real group."
+  (interactive)
+  (let ((gnus-command-method
+	 (gnus-find-method-for-group gnus-newsgroup-name)))
+    (when (gnus-check-backend-function
+	   'warp-to-article (car gnus-command-method))
+      (funcall (gnus-get-function gnus-command-method 'warp-to-article)))))
+
 (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 +664,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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/gnus-kill.el	Mon Nov 08 14:19:54 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-msg.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/gnus-msg.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1628,7 +1628,7 @@
 	    (unless (gnus-check-server method)
 	      (error "Can't open server %s" (if (stringp method) method
 					      (car method))))
-	    (unless (gnus-request-group group nil method)
+	    (unless (gnus-request-group group t method)
 	      (gnus-request-create-group group method))
 	    (setq mml-externalize-attachments
 		  (if (stringp gnus-gcc-externalize-attachments)
@@ -1891,7 +1891,11 @@
 	    (setq v
 		  (cond
 		   ((stringp value)
-		    value)
+		    (if (and (stringp match)
+			     (gnus-string-match-p "\\\\[&[:digit:]]" value)
+			     (match-beginning 1))
+			(gnus-match-substitute-replacement value nil nil group)
+		      value))
 		   ((or (symbolp value)
 			(functionp value))
 		    (cond ((functionp value)
--- a/lisp/gnus/gnus-registry.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/gnus-registry.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/gnus-spec.el	Mon Nov 08 14:19:54 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-srvr.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/gnus-srvr.el	Mon Nov 08 14:19:54 2010 +0900
@@ -34,6 +34,8 @@
 (require 'gnus-int)
 (require 'gnus-range)
 
+(autoload 'gnus-group-make-nnir-group "nnir")
+
 (defcustom gnus-server-mode-hook nil
   "Hook run in `gnus-server-mode' buffers."
   :group 'gnus-server
@@ -165,6 +167,8 @@
 
     "g" gnus-server-regenerate-server
 
+    "G" gnus-group-make-nnir-group
+
     "z" gnus-server-compact-server
 
     "\C-c\C-i" gnus-info-find-node
--- a/lisp/gnus/gnus-start.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/gnus-start.el	Mon Nov 08 14:19:54 2010 +0900
@@ -775,14 +775,6 @@
     (if gnus-agent
 	(gnus-agentize))
 
-    (when gnus-simple-splash
-      (setq gnus-simple-splash nil)
-      (cond
-       ((featurep 'xemacs)
-	(gnus-xmas-splash))
-       (window-system
-	(gnus-x-splash))))
-
     (let ((level (and (numberp arg) (> arg 0) arg))
 	  did-connect)
       (unwind-protect
@@ -1108,53 +1100,53 @@
 			'gnus-subscribe-zombies)
 		  t)
 		 (t gnus-check-new-newsgroups))))
-    (unless (gnus-check-first-time-used)
-      (if (or (consp check)
-	      (eq check 'ask-server))
-	  ;; Ask the server for new groups.
-	  (gnus-ask-server-for-new-groups)
-	;; Go through the active hashtb and look for new groups.
-	(let ((groups 0)
-	      group new-newsgroups)
-	  (gnus-message 5 "Looking for new newsgroups...")
-	  (unless gnus-have-read-active-file
-	    (gnus-read-active-file))
-	  (setq gnus-newsrc-last-checked-date (message-make-date))
-	  (unless gnus-killed-hashtb
-	    (gnus-make-hashtable-from-killed))
-	  ;; Go though every newsgroup in `gnus-active-hashtb' and compare
-	  ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
-	  (mapatoms
-	   (lambda (sym)
-	     (if (or (null (setq group (symbol-name sym)))
-		     (not (boundp sym))
-		     (null (symbol-value sym))
-		     (gnus-gethash group gnus-killed-hashtb)
-		     (gnus-gethash group gnus-newsrc-hashtb))
-		 ()
-	       (let ((do-sub (gnus-matches-options-n group)))
-		 (cond
-		  ((eq do-sub 'subscribe)
-		   (setq groups (1+ groups))
-		   (gnus-sethash group group gnus-killed-hashtb)
-		   (gnus-call-subscribe-functions
-		    gnus-subscribe-options-newsgroup-method group))
-		  ((eq do-sub 'ignore)
-		   nil)
-		  (t
-		   (setq groups (1+ groups))
-		   (gnus-sethash group group gnus-killed-hashtb)
-		   (if gnus-subscribe-hierarchical-interactive
-		       (push group new-newsgroups)
-		     (gnus-call-subscribe-functions
-		      gnus-subscribe-newsgroup-method group)))))))
-	   gnus-active-hashtb)
-	  (when new-newsgroups
-	    (gnus-subscribe-hierarchical-interactive new-newsgroups))
-	  (if (> groups 0)
-	      (gnus-message 5 "%d new newsgroup%s arrived."
-			    groups (if (> groups 1) "s have" " has"))
-	    (gnus-message 5 "No new newsgroups.")))))))
+    (if (or (consp check)
+            (eq check 'ask-server))
+        ;; Ask the server for new groups.
+        (gnus-ask-server-for-new-groups)
+      ;; Go through the active hashtb and look for new groups.
+      (let ((groups 0)
+            group new-newsgroups)
+        (gnus-message 5 "Looking for new newsgroups...")
+        (unless gnus-have-read-active-file
+          (gnus-read-active-file))
+        (setq gnus-newsrc-last-checked-date (message-make-date))
+        (unless gnus-killed-hashtb
+          (gnus-make-hashtable-from-killed))
+        ;; Go though every newsgroup in `gnus-active-hashtb' and compare
+        ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
+        (mapatoms
+         (lambda (sym)
+           (if (or (null (setq group (symbol-name sym)))
+                   (not (boundp sym))
+                   (null (symbol-value sym))
+                   (gnus-gethash group gnus-killed-hashtb)
+                   (gnus-gethash group gnus-newsrc-hashtb))
+               ()
+             (let ((do-sub (gnus-matches-options-n group)))
+               (cond
+                ((eq do-sub 'subscribe)
+                 (setq groups (1+ groups))
+                 (gnus-sethash group group gnus-killed-hashtb)
+                 (gnus-call-subscribe-functions
+                  gnus-subscribe-options-newsgroup-method group))
+                ((eq do-sub 'ignore)
+                 nil)
+                (t
+                 (setq groups (1+ groups))
+                 (gnus-sethash group group gnus-killed-hashtb)
+                 (if gnus-subscribe-hierarchical-interactive
+                     (push group new-newsgroups)
+                   (gnus-call-subscribe-functions
+                    gnus-subscribe-newsgroup-method group)))))))
+         gnus-active-hashtb)
+        (when new-newsgroups
+          (gnus-subscribe-hierarchical-interactive new-newsgroups))
+        (if (> groups 0)
+            (gnus-message 5 "%d new newsgroup%s arrived."
+                          groups (if (> groups 1) "s have" " has"))
+          (gnus-message 5 "No new newsgroups."))
+	groups))))
 
 (defun gnus-matches-options-n (group)
   ;; Returns `subscribe' if the group is to be unconditionally
@@ -1252,54 +1244,7 @@
       (gnus-message 5 "No new newsgroups"))
     (when got-new
       (setq gnus-newsrc-last-checked-date new-date))
-    got-new))
-
-(defun gnus-check-first-time-used ()
-  (catch 'ended
-    ;; First check if any of the following files exist.  If they do,
-    ;; it's not the first time the user has used Gnus.
-    (dolist (file (list (concat gnus-current-startup-file ".el")
-			(concat gnus-current-startup-file ".eld")
-			(concat gnus-startup-file ".el")
-			(concat gnus-startup-file ".eld")))
-      (when (file-exists-p file)
-	(throw 'ended nil)))
-    (gnus-message 6 "First time user; subscribing you to default groups")
-    (unless (gnus-read-active-file-p)
-      (let ((gnus-read-active-file t))
-	(gnus-read-active-file)))
-    (setq gnus-newsrc-last-checked-date (message-make-date))
-    ;; Subscribe to the default newsgroups.
-    (let ((groups (or gnus-default-subscribed-newsgroups
-		      gnus-backup-default-subscribed-newsgroups))
-	  group)
-      (if (eq groups t)
-	  ;; If t, we subscribe (or not) all groups as if they were new.
-	  (mapatoms
-	   (lambda (sym)
-	     (when (setq group (symbol-name sym))
-	       (let ((do-sub (gnus-matches-options-n group)))
-		 (cond
-		  ((eq do-sub 'subscribe)
-		   (gnus-sethash group group gnus-killed-hashtb)
-		   (gnus-call-subscribe-functions
-		    gnus-subscribe-options-newsgroup-method group))
-		  ((eq do-sub 'ignore)
-		   nil)
-		  (t
-		   (push group gnus-killed-list))))))
-	   gnus-active-hashtb)
-	(dolist (group groups)
-	  ;; Only subscribe the default groups that are activated.
-	  (when (gnus-active group)
-	    (gnus-group-change-level
-	     group gnus-level-default-subscribed gnus-level-killed)))
-	(with-current-buffer gnus-group-buffer
-	  ;; Don't error if the group already exists. This happens when a
-	  ;; first-time user types 'F'. -- didier
-	  (gnus-group-make-help-group t))
-	(when gnus-novice-user
-	  (gnus-message 7 "`A k' to list killed groups"))))))
+    new-newsgroups))
 
 (defun gnus-subscribe-group (group &optional previous method)
   "Subscribe GROUP and put it after PREVIOUS."
@@ -1757,16 +1702,20 @@
       (destructuring-bind (method method-type infos dummy) elem
 	(when (and method infos
 		   (not (gnus-method-denied-p method)))
-	  (unless (gnus-server-opened method)
-	    (gnus-open-server method))
-	  (when (and
-		 (gnus-server-opened method)
-		 (gnus-check-backend-function
-		  'retrieve-group-data-early (car method)))
-	    (when (gnus-check-backend-function 'request-scan (car method))
-	      (gnus-request-scan nil method))
-	    (setcar (nthcdr 3 elem)
-		    (gnus-retrieve-group-data-early method infos))))))
+	  ;; If the open-server method doesn't exist, then the method
+	  ;; itself doesn't exist, so we ignore it.
+	  (if (not (ignore-errors (gnus-get-function method 'open-server)))
+	      (setq type-cache (delq elem type-cache))
+	    (unless (gnus-server-opened method)
+	      (gnus-open-server method))
+	    (when (and
+		   (gnus-server-opened method)
+		   (gnus-check-backend-function
+		    'retrieve-group-data-early (car method)))
+	      (when (gnus-check-backend-function 'request-scan (car method))
+		(gnus-request-scan nil method))
+	      (setcar (nthcdr 3 elem)
+		      (gnus-retrieve-group-data-early method infos)))))))
 
     ;; Do the rest of the retrieval.
     (dolist (elem type-cache)
@@ -2037,7 +1986,9 @@
       (while (setq method (pop methods))
 	;; Only do each method once, in case the methods appear more
 	;; than once in this list.
-	(unless (member method methods)
+	(when (and (not (member method methods))
+		   ;; Check whether the backend exists.
+		   (ignore-errors (gnus-get-function method 'open-server)))
 	  (if (or debug-on-error debug-on-quit)
 	      (gnus-read-active-file-1 method force)
 	    (condition-case ()
@@ -2090,7 +2041,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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/gnus-sum.el	Mon Nov 08 14:19:54 2010 +0900
@@ -2061,6 +2061,7 @@
   "D" gnus-summary-enter-digest-group
   "R" gnus-summary-refer-references
   "T" gnus-summary-refer-thread
+  "W" gnus-warp-to-article
   "g" gnus-summary-show-article
   "s" gnus-summary-isearch-article
   "P" gnus-summary-print-article
@@ -2169,8 +2170,7 @@
   "v" gnus-version
   "d" gnus-summary-describe-group
   "h" gnus-summary-describe-briefly
-  "i" gnus-info-find-node
-  "C" gnus-group-fetch-control)
+  "i" gnus-info-find-node)
 
 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
   "e" gnus-summary-expire-articles
@@ -2747,9 +2747,6 @@
 	 ["Original sort" gnus-summary-sort-by-original t])
 	("Help"
 	 ["Describe group" gnus-summary-describe-group t]
-	 ["Fetch control message" gnus-group-fetch-control
-	  ,@(if (featurep 'xemacs) nil
-	      '(:help "Display the archived control message for the current group"))]
 	 ["Read manual" gnus-info-find-node t])
 	("Modes"
 	 ["Pick and read" gnus-pick-mode t]
@@ -4510,7 +4507,7 @@
 	(while (not (eobp))
 	  (ignore-errors
 	    (setq article (read (current-buffer))
-		  header (gnus-nov-parse-line article dependencies)))
+		  header (gnus-nov-parse-line article dependencies t)))
 	  (when header
 	    (with-current-buffer gnus-summary-buffer
 	      (push header gnus-newsgroup-headers)
@@ -5472,7 +5469,7 @@
 			  (substring subject (match-end 1)))))
 	  (mail-header-set-subject header subject))))))
 
-(defun gnus-fetch-headers (articles)
+(defun gnus-fetch-headers (articles &optional limit force-new dependencies)
   "Fetch headers of ARTICLES."
   (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
     (gnus-message 5 "Fetching headers for %s..." name)
@@ -5481,16 +5478,17 @@
 		(setq gnus-headers-retrieved-by
 		      (gnus-retrieve-headers
 		       articles gnus-newsgroup-name
-		       ;; We might want to fetch old headers, but
-		       ;; not if there is only 1 article.
-		       (and (or (and
-				 (not (eq gnus-fetch-old-headers 'some))
-				 (not (numberp gnus-fetch-old-headers)))
-				(> (length articles) 1))
-			    gnus-fetch-old-headers))))
+		       (or limit
+			   ;; We might want to fetch old headers, but
+			   ;; not if there is only 1 article.
+			   (and (or (and
+				     (not (eq gnus-fetch-old-headers 'some))
+				     (not (numberp gnus-fetch-old-headers)))
+				    (> (length articles) 1))
+				gnus-fetch-old-headers)))))
 	    (gnus-get-newsgroup-headers-xover
-	     articles nil nil gnus-newsgroup-name t)
-	  (gnus-get-newsgroup-headers))
+	     articles force-new dependencies gnus-newsgroup-name t)
+	  (gnus-get-newsgroup-headers dependencies force-new))
       (gnus-message 5 "Fetching headers for %s...done" name))))
 
 (defun gnus-select-newsgroup (group &optional read-all select-articles)
@@ -6190,7 +6188,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 +6946,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")
@@ -7025,7 +7031,11 @@
 (defun gnus-summary-rescan-group (&optional all)
   "Exit the newsgroup, ask for new articles, and select the newsgroup."
   (interactive "P")
-  (gnus-summary-reselect-current-group all t))
+  (let ((config gnus-current-window-configuration))
+    (gnus-summary-reselect-current-group all t)
+    (gnus-configure-windows config)
+    (when (eq config 'article)
+      (gnus-summary-select-article))))
 
 (defun gnus-summary-update-info (&optional non-destructive)
   (save-excursion
@@ -7584,9 +7594,11 @@
 		       (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 (get-buffer gnus-original-article-buffer))
 		       (not (eq gnus-current-article article))))
 	      force)
 	  ;; The requested article is different from the current article.
@@ -8290,10 +8302,6 @@
     (gnus-summary-limit articles))
   (gnus-summary-position-point))
 
-(defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
-(make-obsolete
- 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread "Emacs 20.4")
-
 (defun gnus-summary-limit-to-unread (&optional all)
   "Limit the summary buffer to articles that are not marked as read.
 If ALL is non-nil, limit strictly to unread articles."
@@ -8384,10 +8392,6 @@
     (gnus-summary-limit gnus-newsgroup-replied))
   (gnus-summary-position-point))
 
-(defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
-(make-obsolete 'gnus-summary-delete-marked-with
-	       'gnus-summary-limit-exclude-marks "Emacs 20.4")
-
 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
   "Exclude articles that are marked with MARKS (e.g. \"DK\").
 If REVERSE, limit the summary buffer to articles that are marked
@@ -8443,7 +8447,11 @@
 article."
   (interactive (list (mail-header-id (gnus-summary-article-header))))
   (let ((articles (gnus-articles-in-thread
-		   (gnus-id-to-thread (gnus-root-id id)))))
+		   (gnus-id-to-thread (gnus-root-id id))))
+	;;we REALLY want the whole thread---this prevents cut-threads
+	;;from removing the thread we want to include.
+	(gnus-fetch-old-headers nil)
+	(gnus-build-sparse-threads nil))
     (prog1
 	(gnus-summary-limit (nconc articles gnus-newsgroup-limit))
       (gnus-summary-limit-include-matching-articles
@@ -8824,31 +8832,44 @@
 
 (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")
+  (gnus-warp-to-article)
   (let ((id (mail-header-id (gnus-summary-article-header)))
+	(gnus-inhibit-demon t)
+	(gnus-agent nil)
+	(gnus-summary-ignore-duplicates t)
+	(gnus-read-all-available-headers 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))
+    (setq gnus-newsgroup-headers
+	  (gnus-merge
+	   'list gnus-newsgroup-headers
+	   (if (gnus-check-backend-function
+		'request-thread gnus-newsgroup-name)
+	       (gnus-request-thread id)
+	     (let* ((last (if (numberp limit)
+			      (min (+ (mail-header-number
+				       (gnus-summary-article-header))
+				      limit)
+				   gnus-newsgroup-highest)
+			    gnus-newsgroup-highest))
+		    (subject (gnus-simplify-subject
+			      (mail-header-subject
+			       (gnus-summary-article-header))))
+		    (refs (split-string (or (mail-header-references
+					     (gnus-summary-article-header))
+					    "")))
+		    (gnus-parse-headers-hook
+		     (lambda () (goto-char (point-min))
+		       (keep-lines
+			(regexp-opt (append refs (list id subject)))))))
+	       (gnus-fetch-headers (list last) (if (numberp limit)
+						   (* 2 limit) limit) t)))
+	   'gnus-article-sort-by-number))
     (gnus-summary-limit-include-thread id)))
 
 (defun gnus-summary-refer-article (message-id)
@@ -9319,41 +9340,26 @@
   (ps-despool filename))
 
 (defun gnus-print-buffer ()
-  (let ((buffer (generate-new-buffer " *print*")))
-    (unwind-protect
-	(progn
-	  (copy-to-buffer buffer (point-min) (point-max))
-	  (set-buffer buffer)
-	  (gnus-remove-text-with-property 'gnus-decoration)
-	  (when (gnus-visual-p 'article-highlight 'highlight)
-	    ;; Copy-to-buffer doesn't copy overlay.  So redo
-	    ;; highlight.
-	    (let ((gnus-article-buffer buffer))
-	      (gnus-article-highlight-citation t)
-	      (gnus-article-highlight-signature)
-	      (gnus-article-emphasize)
-	      (gnus-article-delete-invisible-text)))
-	  (let ((ps-left-header
-		 (list
-		  (concat "("
-			  (gnus-summary-print-truncate-and-quote
-			   (mail-header-subject gnus-current-headers)
-			   66) ")")
-		  (concat "("
-			  (gnus-summary-print-truncate-and-quote
-			   (mail-header-from gnus-current-headers)
-			   45) ")")))
-		(ps-right-header
-		 (list
-		  "/pagenumberstring load"
-		  (concat "("
-			  (mail-header-date gnus-current-headers) ")"))))
-	    (gnus-run-hooks 'gnus-ps-print-hook)
-	    (save-excursion
-	      (if ps-print-color-p
-		  (ps-spool-buffer-with-faces)
-		(ps-spool-buffer)))))
-      (kill-buffer buffer))))
+  (let ((ps-left-header
+	 (list
+	  (concat "("
+		  (gnus-summary-print-truncate-and-quote
+		   (mail-header-subject gnus-current-headers)
+		   66) ")")
+	  (concat "("
+		  (gnus-summary-print-truncate-and-quote
+		   (mail-header-from gnus-current-headers)
+		   45) ")")))
+	(ps-right-header
+	 (list
+	  "/pagenumberstring load"
+	  (concat "("
+		  (mail-header-date gnus-current-headers) ")"))))
+    (gnus-run-hooks 'gnus-ps-print-hook)
+    (save-excursion
+      (if ps-print-color-p
+	  (ps-spool-buffer-with-faces)
+	(ps-spool-buffer)))))
 
 (defun gnus-summary-show-complete-article ()
   "Show a complete version of the current article.
@@ -9382,9 +9388,10 @@
 If ARG (the prefix) is a number, show the article with the charset
 defined in `gnus-summary-show-article-charset-alist', or the charset
 input.
-If ARG (the prefix) is non-nil and not a number, show the raw article
-without any article massaging functions being run.  Normally, the key
-strokes are `C-u g'."
+If ARG (the prefix) is non-nil and not a number, show the article,
+but without running any of the article treatment functions
+article.  Normally, the keystroke is `C-u g'.  When using `C-u
+C-u g', show the raw article."
   (interactive "P")
   (cond
    ((numberp arg)
@@ -9426,7 +9433,9 @@
    ((not arg)
     ;; Select the article the normal way.
     (gnus-summary-select-article nil 'force))
-   (t
+   ((or (equal arg '(16))
+	(eq arg t))
+    ;; C-u C-u g
     ;; We have to require this here to make sure that the following
     ;; dynamic binding isn't shadowed by autoloading.
     (require 'gnus-async)
@@ -9444,6 +9453,9 @@
 	  ;; Set it to nil for safety reason.
 	  (setq gnus-article-mime-handle-alist nil)
 	  (setq gnus-article-mime-handles nil)))
+      (gnus-summary-select-article nil 'force)))
+   (t
+    (let ((gnus-inhibit-article-treatments t))
       (gnus-summary-select-article nil 'force))))
   (gnus-summary-goto-subject gnus-current-article)
   (gnus-summary-position-point))
@@ -10248,7 +10260,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 +10280,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 +10312,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 +10866,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 +10873,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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/gnus-util.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1651,10 +1651,16 @@
 		       initial-input history def))
 
 
-(autoload 'iswitchb-read-buffer "iswitchb")
+(declare-function iswitchb-read-buffer "iswitchb"
+		  (prompt &optional default require-match start matches-set))
+(defvar iswitchb-temp-buflist)
+
 (defun gnus-iswitchb-completing-read (prompt collection &optional require-match
                                             initial-input history def)
   "`iswitchb' based completing-read function."
+  ;; Make sure iswitchb is loaded before we let-bind its variables.
+  ;; If it is loaded inside the let, variables can become unbound afterwards.
+  (require 'iswitchb)
   (let ((iswitchb-make-buflist-hook
          (lambda ()
            (setq iswitchb-temp-buflist
@@ -1667,11 +1673,11 @@
                    (nreverse filtered-choices))))))
     (unwind-protect
         (progn
-          (when (not iswitchb-mode)
-            (add-hook 'minibuffer-setup-hook 'iswitchb-minibuffer-setup))
+          (or iswitchb-mode
+	      (add-hook 'minibuffer-setup-hook 'iswitchb-minibuffer-setup))
           (iswitchb-read-buffer prompt def require-match))
-      (when (not iswitchb-mode)
-        (remove-hook 'minibuffer-setup-hook 'iswitchb-minibuffer-setup)))))
+      (or iswitchb-mode
+	  (remove-hook 'minibuffer-setup-hook 'iswitchb-minibuffer-setup)))))
 
 (defun gnus-graphic-display-p ()
   (if (featurep 'xemacs)
@@ -1758,14 +1764,16 @@
 	(kill-buffer buf))
     tchar))
 
-(if (fboundp 'select-frame-set-input-focus)
+(if (featurep 'emacs)
     (defalias 'gnus-select-frame-set-input-focus 'select-frame-set-input-focus)
-  ;; XEmacs 21.4, SXEmacs
-  (defun gnus-select-frame-set-input-focus (frame)
-    "Select FRAME, raise it, and set input focus, if possible."
-    (raise-frame frame)
-    (select-frame frame)
-    (focus-frame frame)))
+  (if (fboundp 'select-frame-set-input-focus)
+      (defalias 'gnus-select-frame-set-input-focus 'select-frame-set-input-focus)
+    ;; XEmacs 21.4, SXEmacs
+    (defun gnus-select-frame-set-input-focus (frame)
+      "Select FRAME, raise it, and set input focus, if possible."
+      (raise-frame frame)
+      (select-frame frame)
+      (focus-frame frame))))
 
 (defun gnus-frame-or-window-display-name (object)
   "Given a frame or window, return the associated display name.
@@ -1930,25 +1938,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))
 
@@ -1993,6 +1982,44 @@
                    image)))
       image)))
 
+(defun gnus-list-memq-of-list (elements list)
+  "Return non-nil if any of the members of ELEMENTS are in LIST."
+  (let ((found nil))
+    (dolist (elem elements)
+      (setq found (or found
+		      (memq elem list))))
+    found))
+
+(eval-and-compile
+  (cond
+   ((fboundp 'match-substitute-replacement)
+    (defalias 'gnus-match-substitute-replacement 'match-substitute-replacement))
+   (t
+    (defun gnus-match-substitute-replacement (replacement &optional fixedcase literal string subexp)
+      "Return REPLACEMENT as it will be inserted by `replace-match'.
+In other words, all back-references in the form `\\&' and `\\N'
+are substituted with actual strings matched by the last search.
+Optional FIXEDCASE, LITERAL, STRING and SUBEXP have the same
+meaning as for `replace-match'.
+
+This is the definition of match-substitute-replacement in subr.el from GNU Emacs."
+      (let ((match (match-string 0 string)))
+	(save-match-data
+	  (set-match-data (mapcar (lambda (x)
+				    (if (numberp x)
+					(- x (match-beginning 0))
+				      x))
+				  (match-data t)))
+	  (replace-match replacement fixedcase literal match subexp)))))))
+
+(if (fboundp 'string-match-p)
+    (defalias 'gnus-string-match-p 'string-match-p)
+  (defsubst gnus-string-match-p (regexp string &optional start)
+    "\
+Same as `string-match' except this function does not change the match data."
+    (save-match-data
+      (string-match regexp string start))))
+
 (provide 'gnus-util)
 
 ;;; gnus-util.el ends here
--- a/lisp/gnus/gnus.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/gnus.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,8 +1,8 @@
 ;;; gnus.el --- a newsreader for GNU Emacs
 
-;; Copyright (C) 1987, 1988, 1989, 1990, 1993, 1994, 1995, 1996, 1997, 1998,
-;;   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-;;   Free Software Foundation, Inc.
+;; Copyright (C) 1987, 1988, 1989, 1990, 1993, 1994, 1995, 1996, 1997,
+;;   1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
+;;   2010  Free Software Foundation, Inc.
 
 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
 ;;	Lars Magne Ingebrigtsen <larsi@gnus.org>
@@ -308,9 +308,6 @@
   :group 'gnus-start
   :type 'boolean)
 
-(unless (fboundp 'gnus-group-remove-excess-properties)
-  (defalias 'gnus-group-remove-excess-properties 'ignore))
-
 (unless (featurep 'gnus-xmas)
   (defalias 'gnus-make-overlay 'make-overlay)
   (defalias 'gnus-delete-overlay 'delete-overlay)
@@ -353,7 +350,6 @@
 		     (list str))
 	    line)))
     (defalias 'gnus-mode-line-buffer-identification 'identity))
-  (defalias 'gnus-characterp 'numberp)
   (defalias 'gnus-deactivate-mark 'deactivate-mark)
   (defalias 'gnus-window-edges 'window-edges)
   (defalias 'gnus-key-press-event-p 'numberp)
@@ -921,7 +917,8 @@
 ;;; Gnus buffers
 ;;;
 
-(defvar gnus-buffers nil)
+(defvar gnus-buffers nil
+  "List of buffers handled by Gnus.")
 
 (defun gnus-get-buffer-create (name)
   "Do the same as `get-buffer-create', but store the created buffer."
@@ -953,7 +950,8 @@
 
 ;;; Splash screen.
 
-(defvar gnus-group-buffer "*Group*")
+(defvar gnus-group-buffer "*Group*"
+  "Name of the Gnus group buffer.")
 
 (defface gnus-splash
   '((((class color)
@@ -992,8 +990,6 @@
 	(while (search-forward "\t" nil t)
 	  (replace-match "        " t t))))))
 
-(defvar gnus-simple-splash nil)
-
 ;;(format "%02x%02x%02x" 114 66 20) "724214"
 
 (defvar gnus-logo-color-alist
@@ -1033,50 +1029,47 @@
   "Insert startup message in current buffer."
   ;; Insert the message.
   (erase-buffer)
-  (cond
-   ((and
-     (fboundp 'find-image)
-     (display-graphic-p)
-     ;; Make sure the library defining `image-load-path' is loaded
-     ;; (`find-image' is autoloaded) (and discard the result).  Else, we may
-     ;; get "defvar ignored because image-load-path is let-bound" when calling
-     ;; `find-image' below.
-     (or (find-image '(nil (:type xpm :file "gnus.xpm"))) t)
-     (let* ((data-directory (nnheader-find-etc-directory "images/gnus"))
-	    (image-load-path (cond (data-directory
-				    (list data-directory))
-				   ((boundp 'image-load-path)
-				    (symbol-value 'image-load-path))
-				   (t load-path)))
-	    (image (find-image
-		    `((:type xpm :file "gnus.xpm"
-			     :color-symbols
-			     (("thing" . ,(car gnus-logo-colors))
-			      ("shadow" . ,(cadr gnus-logo-colors))
-			      ("oort" . "#eeeeee")
-			      ("background" . ,(face-background 'default))))
-		      (:type svg :file "gnus.svg")
-		      (:type png :file "gnus.png")
-		      (:type pbm :file "gnus.pbm"
-			     ;; Account for the pbm's blackground.
-			     :background ,(face-foreground 'gnus-splash)
-			     :foreground ,(face-background 'default))
-		      (:type xbm :file "gnus.xbm"
-			     ;; Account for the xbm's blackground.
-			     :background ,(face-foreground 'gnus-splash)
-			     :foreground ,(face-background 'default))))))
-       (when image
-	 (let ((size (image-size image)))
-	   (insert-char ?\n (max 0 (round (- (window-height)
-					     (or y (cdr size)) 1) 2)))
-	   (insert-char ?\  (max 0 (round (- (window-width)
-					     (or x (car size))) 2)))
-	   (insert-image image))
-	 (setq gnus-simple-splash nil)
-	 t))))
-   (t
+  (unless (and
+           (fboundp 'find-image)
+           (display-graphic-p)
+           ;; Make sure the library defining `image-load-path' is
+           ;; loaded (`find-image' is autoloaded) (and discard the
+           ;; result).  Else, we may get "defvar ignored because
+           ;; image-load-path is let-bound" when calling `find-image'
+           ;; below.
+           (or (find-image '(nil (:type xpm :file "gnus.xpm"))) t)
+           (let* ((data-directory (nnheader-find-etc-directory "images/gnus"))
+                  (image-load-path (cond (data-directory
+                                          (list data-directory))
+                                         ((boundp 'image-load-path)
+                                          (symbol-value 'image-load-path))
+                                         (t load-path)))
+                  (image (find-image
+                          `((:type xpm :file "gnus.xpm"
+                                   :color-symbols
+                                   (("thing" . ,(car gnus-logo-colors))
+                                    ("shadow" . ,(cadr gnus-logo-colors))))
+                            (:type svg :file "gnus.svg")
+                            (:type png :file "gnus.png")
+                            (:type pbm :file "gnus.pbm"
+                                   ;; Account for the pbm's background.
+                                   :background ,(face-foreground 'gnus-splash)
+                                   :foreground ,(face-background 'default))
+                            (:type xbm :file "gnus.xbm"
+                                   ;; Account for the xbm's background.
+                                   :background ,(face-foreground 'gnus-splash)
+                                   :foreground ,(face-background 'default))))))
+             (when image
+               (let ((size (image-size image)))
+                 (insert-char ?\n (max 0 (round (- (window-height)
+                                                   (or y (cdr size)) 1) 2)))
+                 (insert-char ?\  (max 0 (round (- (window-width)
+                                                   (or x (car size))) 2)))
+                 (insert-image image))
+	       (goto-char (point-min))
+               t)))
     (insert
-     (format "              %s
+     (format "
 	  _    ___ _             _
 	  _ ___ __ ___  __    _ ___
 	  __   _     ___    __  ___
@@ -1095,8 +1088,7 @@
 	    _
 	  __
 
-"
-	     ""))
+"))
     ;; And then hack it.
     (gnus-indent-rigidly (point-min) (point-max)
 			 (/ (max (- (window-width) (or x 46)) 0) 2))
@@ -1108,10 +1100,9 @@
       (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
     ;; Fontify some.
     (put-text-property (point-min) (point-max) 'face 'gnus-splash)
-    (setq gnus-simple-splash t)))
-  (goto-char (point-min))
-  (setq mode-line-buffer-identification (concat " " gnus-version))
-  (set-buffer-modified-p t))
+    (goto-char (point-min))
+    (setq mode-line-buffer-identification (concat " " gnus-version))
+    (set-buffer-modified-p t)))
 
 (eval-when (load)
   (let ((command (format "%s" this-command)))
@@ -1267,15 +1258,6 @@
 If you want to change servers, you should use `gnus-select-method'.
 See the documentation to that variable.")
 
-;; Don't touch this variable.
-(defvar gnus-nntp-service "nntp"
-  "NNTP service name (\"nntp\" or 119).
-This is an obsolete variable, which is scarcely used.  If you use an
-nntp server for your newsgroup and want to change the port number
-used to 899, you would say something along these lines:
-
- (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
-
 (defcustom gnus-nntpserver-file "/etc/nntpserver"
   "A file with only the name of the nntp server in it."
   :group 'gnus-files
@@ -1299,20 +1281,11 @@
 ;;;###autoload  (custom-autoload 'gnus-select-method "gnus"))
 
 (defcustom gnus-select-method
-  (condition-case nil
-      (nconc
-       (list 'nntp (or (condition-case nil
-			   (gnus-getenv-nntpserver)
-			 (error nil))
-		       (when (and gnus-default-nntp-server
-				  (not (string= gnus-default-nntp-server "")))
-			 gnus-default-nntp-server)
-		       "news"))
-       (if (or (null gnus-nntp-service)
-	       (equal gnus-nntp-service "nntp"))
-	   nil
-	 (list gnus-nntp-service)))
-    (error nil))
+  (list 'nntp (or (gnus-getenv-nntpserver)
+                  (when (and gnus-default-nntp-server
+                             (not (string= gnus-default-nntp-server "")))
+                    gnus-default-nntp-server)
+                  "news"))
   "Default method for selecting a newsgroup.
 This variable should be a list, where the first element is how the
 news is to be fetched, the second is the address.
@@ -1356,12 +1329,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 +1354,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))
@@ -1393,14 +1370,14 @@
 non-numeric prefix - `C-u M-x gnus', in short."
   :group 'gnus-server
   :type '(repeat string))
+(make-obsolete-variable 'gnus-secondary-servers 'gnus-select-method "24.1")
 
 (defcustom gnus-nntp-server nil
-  "*The name of the host running the NNTP server.
-This variable is semi-obsolete.  Use the `gnus-select-method'
-variable instead."
+  "The name of the host running the NNTP server."
   :group 'gnus-server
   :type '(choice (const :tag "disable" nil)
 		 string))
+(make-obsolete-variable 'gnus-nntp-server 'gnus-select-method "24.1")
 
 (defcustom gnus-secondary-select-methods nil
   "A list of secondary methods that will be used for reading news.
@@ -1414,11 +1391,6 @@
   :group 'gnus-server
   :type '(repeat gnus-select-method))
 
-(defvar gnus-backup-default-subscribed-newsgroups
-  '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
-  "Default default new newsgroups the first time Gnus is run.
-Should be set in paths.el, and shouldn't be touched by the user.")
-
 (defcustom gnus-local-domain nil
   "Local domain name without a host name.
 The DOMAINNAME environment variable is used instead if it is defined.
@@ -1462,14 +1434,6 @@
 					(nnweb "refer" (nnweb-type google)))
 				 gnus-select-method))))
 
-(defcustom gnus-group-fetch-control-use-browse-url nil
-  "*Non-nil means that control messages are displayed using `browse-url'.
-Otherwise they are fetched with ange-ftp and displayed in an ephemeral
-group."
-  :version "22.1"
-  :group 'gnus-group-various
-  :type 'boolean)
-
 (defcustom gnus-use-cross-reference t
   "*Non-nil means that cross referenced articles will be marked as read.
 If nil, ignore cross references.  If t, mark articles as read in
@@ -1499,7 +1463,7 @@
 		 integer))
 
 (defcustom gnus-use-long-file-name (not (memq system-type '(usg-unix-v)))
-  "*Non-nil means that the default name of a file to save articles in is the group name.
+  "Non-nil means that the default name of a file to save articles in is the group name.
 If it's nil, the directory form of the group name is used instead.
 
 If this variable is a list, and the list contains the element
@@ -1509,8 +1473,8 @@
 will not be used for kill files.
 
 Note that the default for this variable varies according to what system
-type you're using.  On `usg-unix-v' and `xenix' this variable defaults
-to nil while on all other systems it defaults to t."
+type you're using.  On `usg-unix-v' this variable defaults to nil while
+on all other systems it defaults to t."
   :group 'gnus-start
   :type '(radio (sexp :format "Non-nil\n"
 		      :match (lambda (widget value)
@@ -2810,7 +2774,8 @@
      ("gnus-cite" :interactive t
       gnus-article-highlight-citation gnus-article-hide-citation-maybe
       gnus-article-hide-citation gnus-article-fill-cited-article
-      gnus-article-hide-citation-in-followups)
+      gnus-article-hide-citation-in-followups
+      gnus-article-fill-cited-long-lines)
      ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
       gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
       gnus-execute gnus-expunge gnus-batch-kill gnus-batch-score)
@@ -2911,6 +2876,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)
@@ -3580,16 +3546,6 @@
 					    gnus-valid-select-methods)))
 		 (equal (nth 1 m1) (nth 1 m2)))))))
 
-(defun gnus-methods-sloppily-equal (m1 m2)
-  ;; Same method.
-  (or
-   (eq m1 m2)
-   ;; Type and name are equal.
-   (and
-    (eq (car m1) (car m2))
-    (equal (cadr m1) (cadr m2))
-    (gnus-sloppily-equal-method-parameters m1 m2))))
-
 (defsubst gnus-sloppily-equal-method-parameters (m1 m2)
   ;; Check parameters for sloppy equalness.
   (let ((p1 (copy-sequence (cddr m1)))
@@ -3618,6 +3574,16 @@
       ;; If p2 now is empty, they were equal.
       (null p2))))
 
+(defun gnus-methods-sloppily-equal (m1 m2)
+  ;; Same method.
+  (or
+   (eq m1 m2)
+   ;; Type and name are equal.
+   (and
+    (eq (car m1) (car m2))
+    (equal (cadr m1) (cadr m2))
+    (gnus-sloppily-equal-method-parameters m1 m2))))
+
 (defun gnus-server-equal (m1 m2)
   "Say whether two methods are equal."
   (let ((m1 (cond ((null m1) gnus-select-method)
@@ -3937,7 +3903,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/mail-source.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/mail-source.el	Mon Nov 08 14:19:54 2010 +0900
@@ -501,6 +501,8 @@
    (t
     value)))
 
+(autoload 'nnheader-message "nnheader")
+
 (defun mail-source-fetch (source callback &optional method)
   "Fetch mail from SOURCE and call CALLBACK zero or more times.
 CALLBACK will be called with the name of the file where (some of)
@@ -594,6 +596,8 @@
 	0)
     (funcall callback mail-source-crash-box info)))
 
+(autoload 'gnus-float-time "gnus-util")
+
 (defvar mail-source-incoming-last-checked-time nil)
 
 (defun mail-source-delete-crash-box ()
@@ -614,7 +618,7 @@
 	  ;; Don't check for old incoming files more than once per day to
 	  ;; save a lot of file accesses.
 	  (when (or (null mail-source-incoming-last-checked-time)
-		    (> (time-to-seconds
+		    (> (gnus-float-time
 			(time-since mail-source-incoming-last-checked-time))
 		       (* 24 60 60)))
 	    (setq mail-source-incoming-last-checked-time (current-time))
--- a/lisp/gnus/message.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/message.el	Mon Nov 08 14:19:54 2010 +0900
@@ -306,7 +306,7 @@
 
 ;;; Start of variables adopted from `message-utils.el'.
 
-(defcustom message-subject-trailing-was-query 'ask
+(defcustom message-subject-trailing-was-query t
   "*What to do with trailing \"(was: <old subject>)\" in subject lines.
 If nil, leave the subject unchanged.  If it is the symbol `ask', query
 the user what do do.  In this case, the subject is matched against
@@ -314,7 +314,7 @@
 `message-subject-trailing-was-query' is t, always strip the trailing
 old subject.  In this case, `message-subject-trailing-was-regexp' is
 used."
-  :version "22.1"
+  :version "24.1"
   :type '(choice (const :tag "never" nil)
 		 (const :tag "always strip" t)
 		 (const ask))
@@ -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"))
@@ -4479,6 +4482,8 @@
 	      (save-restriction
 		(message-narrow-to-headers)
 		(and news
+		     (not (message-fetch-field "List-Post"))
+		     (not (message-fetch-field "List-ID"))
 		     (or (message-fetch-field "cc")
 			 (message-fetch-field "bcc")
 			 (message-fetch-field "to"))
@@ -4495,7 +4500,9 @@
 			 (string= "base64"
 				  (message-fetch-field
 				   "content-transfer-encoding")))))))
-	    (message-insert-courtesy-copy))
+	    (message-insert-courtesy-copy
+	     (with-current-buffer mailbuf
+	       message-courtesy-message)))
           ;; Let's make sure we encoded all the body.
           (assert (save-excursion
                     (goto-char (point-min))
@@ -5936,7 +5943,7 @@
       ;; Check for IDNA
       (message-idna-to-ascii-rhs))))
 
-(defun message-insert-courtesy-copy ()
+(defun message-insert-courtesy-copy (message)
   "Insert a courtesy message in mail copies of combined messages."
   (let (newsgroups)
     (save-excursion
@@ -5946,12 +5953,12 @@
 	  (goto-char (point-max))
 	  (insert "Posted-To: " newsgroups "\n")))
       (forward-line 1)
-      (when message-courtesy-message
+      (when message
 	(cond
-	 ((string-match "%s" message-courtesy-message)
-	  (insert (format message-courtesy-message newsgroups)))
+	 ((string-match "%s" message)
+	  (insert (format message newsgroups)))
 	 (t
-	  (insert message-courtesy-message)))))))
+	  (insert message)))))))
 
 ;;;
 ;;; Setting up a message buffer
@@ -6363,7 +6370,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 +6578,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 +6617,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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/mm-decode.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,7 @@
 ;;; mm-decode.el --- Functions for decoding MIME things
 
-;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+;;   2007, 2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;;	MORIOKA Tomohiko <morioka@jaist.ac.jp>
@@ -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")
@@ -1255,11 +1251,13 @@
       (setq filename (gnus-map-function mm-file-name-rewrite-functions
 					(file-name-nondirectory filename))))
     (setq file
-          (read-file-name (or prompt
-			      (format "Save MIME part to (default %s): "
-				      (or filename "")))
-                          (or mm-default-directory default-directory)
-			  (or filename "")))
+          (read-file-name
+	   (or prompt
+	       (format "Save MIME part to (default %s): "
+		       (or filename "")))
+	   (or mm-default-directory default-directory)
+	   (expand-file-name (or filename "")
+			     (or mm-default-directory default-directory))))
     (if (file-directory-p file)
 	(setq file (expand-file-name filename file))
       (setq file (expand-file-name
@@ -1328,6 +1326,8 @@
       (let ((coding-system-for-write 'binary))
 	(shell-command-on-region (point-min) (point-max) command nil)))))
 
+(autoload 'gnus-completing-read "gnus-util")
+
 (defun mm-interactively-view-part (handle)
   "Display HANDLE using METHOD."
   (let* ((type (mm-handle-media-type handle))
@@ -1686,13 +1686,18 @@
 (declare-function libxml-parse-html-region "xml.c"
 		  (start end &optional base-url))
 (declare-function shr-insert-document "shr" (dom))
+(defvar shr-blocked-images)
+(autoload 'gnus-blocked-images "gnus-art")
 
 (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 +1718,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-util.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/mm-util.el	Mon Nov 08 14:19:54 2010 +0900
@@ -39,6 +39,10 @@
     (require 'timer)))
 
 (defvar mm-mime-mule-charset-alist )
+;; Note this is not presently used on Emacs >= 23, which is good,
+;; since it means standalone message-mode (which requires mml and
+;; hence mml-util) does not load gnus-util.
+(autoload 'gnus-completing-read "gnus-util")
 
 ;; Emulate functions that are not available in every (X)Emacs version.
 ;; The name of a function is prefixed with mm-, like `mm-char-int' for
@@ -202,19 +206,10 @@
     (defalias 'mm-decode-coding-region 'decode-coding-region)
     (defalias 'mm-encode-coding-region 'encode-coding-region)))
 
-;; `string-to-multibyte' is available only in Emacs 22.1 or greater.
-(defalias 'mm-string-to-multibyte
-  (cond
-   ((featurep 'xemacs)
-    'identity)
-   ((fboundp 'string-to-multibyte)
-    'string-to-multibyte)
-   (t
-    (lambda (string)
-      "Return a multibyte string with the same individual chars as STRING."
-      (mapconcat
-       (lambda (ch) (mm-string-as-multibyte (char-to-string ch)))
-       string "")))))
+;; `string-to-multibyte' is available only in Emacs.
+(defalias 'mm-string-to-multibyte (if (featurep 'xemacs)
+				      'identity
+				    'string-to-multibyte))
 
 ;; `char-or-char-int-p' is an XEmacs function, not available in Emacs.
 (eval-and-compile
@@ -272,18 +267,19 @@
 ;; Actually, there should be an `mm-coding-system-mime-charset'.
 (eval-and-compile
   (defalias 'mm-read-coding-system
-    (cond
-     ((fboundp 'read-coding-system)
-      (if (and (featurep 'xemacs)
-	       (<= (string-to-number emacs-version) 21.1))
-	  (lambda (prompt &optional default-coding-system)
-	    (read-coding-system prompt))
-	'read-coding-system))
-     (t (lambda (prompt &optional default-coding-system)
-	  "Prompt the user for a coding system."
-	  (gnus-completing-read
-	   prompt (mapcar (lambda (s) (symbol-name (car s)))
-			  mm-mime-mule-charset-alist)))))))
+    (if (featurep 'emacs) 'read-coding-system
+      (cond
+       ((fboundp 'read-coding-system)
+	(if (and (featurep 'xemacs)
+		 (<= (string-to-number emacs-version) 21.1))
+	    (lambda (prompt &optional default-coding-system)
+	      (read-coding-system prompt))
+	  'read-coding-system))
+       (t (lambda (prompt &optional default-coding-system)
+	    "Prompt the user for a coding system."
+	    (gnus-completing-read
+	     prompt (mapcar (lambda (s) (symbol-name (car s)))
+			    mm-mime-mule-charset-alist))))))))
 
 (defvar mm-coding-system-list nil)
 (defun mm-get-coding-system-list ()
--- a/lisp/gnus/mm-view.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/mm-view.el	Mon Nov 08 14:19:54 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
@@ -92,6 +82,8 @@
 ;;; Functions for displaying various formats inline
 ;;;
 
+(autoload 'gnus-rescale-image "gnus-util")
+
 (defun mm-inline-image-emacs (handle)
   (let ((b (point-marker))
 	(inhibit-read-only t))
@@ -426,7 +418,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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/mml.el	Mon Nov 08 14:19:54 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/nndiary.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/nndiary.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1061,9 +1061,9 @@
 		   (file-directory-p dir))
 	  (nndiary-generate-nov-databases-1 dir seen))))
     ;; Do this directory.
-    (let ((files (sort (nnheader-article-to-file-alist dir)
+    (let ((nndiary-files (sort (nnheader-article-to-file-alist dir)
 		       'car-less-than-car)))
-      (if (not files)
+      (if (not nndiary-files)
 	  (let* ((group (nnheader-file-to-group
 			 (directory-file-name dir) nndiary-directory))
 		 (info (cadr (assoc group nndiary-group-alist))))
@@ -1071,11 +1071,11 @@
 	      (setcar info (1+ (cdr info)))))
 	(funcall nndiary-generate-active-function dir)
 	;; Generate the nov file.
-	(nndiary-generate-nov-file dir files)
+	(nndiary-generate-nov-file dir nndiary-files)
 	(unless no-active
 	  (nnmail-save-active nndiary-group-alist nndiary-active-file))))))
 
-(defvar files)
+(defvar nndiary-files) ; dynamically bound in nndiary-generate-nov-databases-1
 (defun nndiary-generate-active-info (dir)
   ;; Update the active info for this group.
   (let* ((group (nnheader-file-to-group
@@ -1084,9 +1084,9 @@
 	 (last (or (caadr entry) 0)))
     (setq nndiary-group-alist (delq entry nndiary-group-alist))
     (push (list group
-		(cons (or (caar files) (1+ last))
+		(cons (or (caar nndiary-files) (1+ last))
 		      (max last
-			   (or (caar (last files))
+			   (or (caar (last nndiary-files))
 			       0))))
 	  nndiary-group-alist)))
 
--- a/lisp/gnus/nndoc.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/nndoc.el	Mon Nov 08 14:19:54 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))
@@ -879,7 +918,8 @@
 	    (setq body-end (point))
 	    (push (list (incf i) head-begin head-end body-begin body-end
 			(count-lines body-begin body-end))
-		  nndoc-dissection-alist)))))))
+		  nndoc-dissection-alist)))))
+    (setq nndoc-dissection-alist (nreverse nndoc-dissection-alist))))
 
 (defun nndoc-article-begin ()
   (if nndoc-article-begin-function
--- a/lisp/gnus/nnimap.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/nnimap.el	Mon Nov 08 14:19:54 2010 +0900
@@ -44,6 +44,10 @@
 (require 'utf7)
 (require 'tls)
 (require 'parse-time)
+(require 'nnmail)
+
+(eval-when-compile
+  (require 'gnus-sum))
 
 (autoload 'auth-source-forget-user-or-password "auth-source")
 (autoload 'auth-source-user-or-password "auth-source")
@@ -78,6 +82,9 @@
 (defvoo nnimap-split-fancy nil
   "Uses the same syntax as nnmail-split-fancy.")
 
+(defvoo nnimap-unsplittable-articles '(%Deleted %Seen)
+  "Articles with the flags in the list will not be considered when splitting.")
+
 (make-obsolete-variable 'nnimap-split-rule "see `nnimap-split-methods'"
 			"Emacs 24.1")
 
@@ -136,6 +143,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 +163,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 +181,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 +210,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)))))
@@ -280,7 +291,7 @@
 	(with-current-buffer buffer
 	  (when (and nnimap-object
 		     (nnimap-last-command-time nnimap-object)
-		     (> (time-to-seconds
+		     (> (gnus-float-time
 			 (time-subtract
 			  now
 			  (nnimap-last-command-time nnimap-object)))
@@ -288,7 +299,8 @@
 			(* 5 60)))
 	    (nnimap-send-command "NOOP")))))))
 
-(declare-function gnutls-negotiate "subr" (fn file &optional arglist fileonly))
+(declare-function gnutls-negotiate "gnutls"
+		  (proc type &optional priority-string trustfiles keyfiles))
 
 (defun nnimap-open-connection (buffer)
   (unless nnimap-keepalive-timer
@@ -304,6 +316,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 +327,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)
@@ -367,14 +387,13 @@
 	    ;; connection and start a STARTTLS connection instead.
 	    (cond
 	     ((and (or (and (eq nnimap-stream 'network)
-			    (member "STARTTLS"
-				    (nnimap-capabilities nnimap-object)))
+			    (nnimap-capability "STARTTLS"))
 		       (eq nnimap-stream 'starttls))
 		   (fboundp 'open-gnutls-stream))
 	      (nnimap-command "STARTTLS")
 	      (gnutls-negotiate (nnimap-process nnimap-object) nil))
 	     ((and (eq nnimap-stream 'network)
-		   (member "STARTTLS" (nnimap-capabilities nnimap-object)))
+		   (nnimap-capability "STARTTLS"))
 	      (let ((nnimap-stream 'starttls))
 		(let ((tls-process
 		       (nnimap-open-connection buffer)))
@@ -400,9 +419,18 @@
 				;; physical address.
 				(nnimap-credentials nnimap-address ports)))))
 		  (setq nnimap-object nil)
-		(setq login-result (nnimap-command "LOGIN %S %S"
-						   (car credentials)
-						   (cadr credentials)))
+		(setq login-result
+		      (if (and (nnimap-capability "AUTH=PLAIN")
+			       (nnimap-capability "LOGINDISABLED"))
+			  (nnimap-command
+			   "AUTHENTICATE PLAIN %s"
+			   (base64-encode-string
+			    (format "\000%s\000%s"
+				    (nnimap-quote-specials (car credentials))
+				    (nnimap-quote-specials (cadr credentials)))))
+			(nnimap-command "LOGIN %S %S"
+					(car credentials)
+					(cadr credentials))))
 		(unless (car login-result)
 		  ;; If the login failed, then forget the credentials
 		  ;; that are now possibly cached.
@@ -415,22 +443,19 @@
 		  (delete-process (nnimap-process nnimap-object))
 		  (setq nnimap-object nil))))
 	    (when nnimap-object
-	      (when (member "QRESYNC" (nnimap-capabilities nnimap-object))
+	      (when (nnimap-capability "QRESYNC")
 		(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-quote-specials (string)
+  (with-temp-buffer
+    (insert string)
+    (goto-char (point-min))
+    (while (re-search-forward "[\\\"]" nil t)
+      (forward-char -1)
+      (insert "\\")
+      (forward-char 1))
+    (buffer-string)))
 
 (defun nnimap-find-parameter (parameter elems)
   (let (result)
@@ -448,6 +473,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 +507,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 +520,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))
@@ -517,8 +559,11 @@
 	(delete-region (point) (point-max)))
       t)))
 
+(defun nnimap-capability (capability)
+  (member capability (nnimap-capabilities nnimap-object)))
+
 (defun nnimap-ver4-p ()
-  (member "IMAP4REV1" (nnimap-capabilities nnimap-object)))
+  (nnimap-capability "IMAP4REV1"))
 
 (defun nnimap-get-partial-article (article parts structure)
   (let ((result
@@ -569,9 +614,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 +666,14 @@
     (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 (and dont-check
+			  (assoc group nnimap-current-infos))
+		     nil
+		   group)
+		 server))
 	articles active marks high low)
     (with-current-buffer nntp-server-buffer
       (when result
@@ -638,6 +690,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
@@ -646,7 +699,8 @@
 				  1 group "SELECT")))))
 	      (when (and info
 			 marks)
-		(nnimap-update-infos marks (list info)))
+		(nnimap-update-infos marks (list info))
+		(nnimap-store-info info (gnus-active (gnus-info-group info))))
 	      (goto-char (point-max))
 	      (let ((uidnext (nth 5 (car marks))))
 		(setq high (or (if uidnext
@@ -673,9 +727,10 @@
 (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))
-      (setf (nnimap-group nnimap-object) nil)
+      ;; 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.
       (car (nnimap-command "RENAME %S %S"
 			   (utf7-encode group t) (utf7-encode new-name t))))))
 
@@ -708,7 +763,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 +797,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 +822,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
@@ -801,8 +861,9 @@
 (defun nnimap-find-article-by-message-id (group message-id)
   (with-current-buffer (nnimap-buffer)
     (erase-buffer)
-    (setf (nnimap-group nnimap-object) nil)
-    (nnimap-send-command "EXAMINE %S" (utf7-encode group t))
+    (unless (equal group (nnimap-group nnimap-object))
+      (setf (nnimap-group nnimap-object) nil)
+      (nnimap-send-command "EXAMINE %S" (utf7-encode group t)))
     (let ((sequence
 	   (nnimap-send-command "UID SEARCH HEADER Message-Id %S" message-id))
 	  article result)
@@ -819,7 +880,7 @@
     (nnimap-command "UID STORE %s +FLAGS.SILENT (\\Deleted)"
 		    (nnimap-article-ranges articles))
     (cond
-     ((member "UIDPLUS" (nnimap-capabilities nnimap-object))
+     ((nnimap-capability "UIDPLUS")
       (nnimap-command "UID EXPUNGE %s"
 		      (nnimap-article-ranges articles))
       t)
@@ -834,7 +895,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,11 +934,14 @@
     (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)
+	(erase-buffer)
 	(setq sequence (nnimap-send-command
 			"APPEND %S {%d}" (utf7-encode group t)
 			(length message)))
+	(unless nnimap-streaming
+	  (nnimap-wait-for-connection "^[+]"))
 	(process-send-string (get-buffer-process (current-buffer)) message)
 	(process-send-string (get-buffer-process (current-buffer))
 			     (if (nnimap-newlinep nnimap-object)
@@ -886,11 +950,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,8 +1042,7 @@
     (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)))
+      (let ((qresyncp (nnimap-capability "QRESYNC"))
 	    params groups sequences active uidvalidity modseq group)
 	;; Go through the infos and gather the data needed to know
 	;; what and how to request the data.
@@ -1006,12 +1080,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 +1175,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 +1207,33 @@
 			    (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 (car (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 +1376,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 +1396,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))))))
+     nil t)))
+
 (defun nnimap-possibly-change-group (group server)
   (let ((open-result t))
     (when (and server
@@ -1364,6 +1459,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)
@@ -1389,12 +1488,14 @@
   (nnimap-wait-for-response sequence)
   (nnimap-parse-response))
 
-(defun nnimap-wait-for-connection ()
+(defun nnimap-wait-for-connection (&optional regexp)
+  (unless regexp
+    (setq regexp "^[*.] .*\n"))
   (let ((process (get-buffer-process (current-buffer))))
     (goto-char (point-min))
     (while (and (memq (process-status process)
 		      '(open run))
-		(not (re-search-forward "^[*.] .*\n" nil t)))
+		(not (re-search-forward regexp nil t)))
       (nnheader-accept-process-output process)
       (goto-char (point-min)))
     (forward-line -1)
@@ -1416,7 +1517,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 +1544,7 @@
 (defun nnimap-parse-line (line)
   (let (char result)
     (with-temp-buffer
+      (mm-disable-multibyte)
       (insert line)
       (goto-char (point-min))
       (while (not (eobp))
@@ -1454,12 +1556,16 @@
 	     (split-string
 	      (buffer-substring
 	       (1+ (point))
-	       (1- (search-forward "]" (line-end-position) 'move)))))
+	       (if (search-forward "]" (line-end-position) 'move)
+		   (1- (point))
+		 (point)))))
 	    ((eql char ?\()
 	     (split-string
 	      (buffer-substring
 	       (1+ (point))
-	       (1- (search-forward ")" (line-end-position) 'move)))))
+	       (if (search-forward ")" (line-end-position) 'move)
+		   (1- (point))
+		 (point)))))
 	    ((eql char ?\")
 	     (forward-char 1)
 	     (buffer-substring
@@ -1527,6 +1633,7 @@
 	  new-articles)
       (erase-buffer)
       (nnimap-command "SELECT %S" nnimap-inbox)
+      (setf (nnimap-group nnimap-object) nnimap-inbox)
       (setq new-articles (nnimap-new-articles (nnimap-get-flags "1:*")))
       (when new-articles
 	(nnimap-fetch-inbox new-articles)
@@ -1579,7 +1686,7 @@
       (cond
        ;; If the server supports it, we now delete the message we have
        ;; just copied over.
-       ((member "UIDPLUS" (nnimap-capabilities nnimap-object))
+       ((nnimap-capability "UIDPLUS")
 	(setq sequence (nnimap-send-command "UID EXPUNGE %s" range)))
        ;; If it doesn't support UID EXPUNGE, then we only expunge if the
        ;; user has configured it.
@@ -1599,9 +1706,8 @@
 (defun nnimap-new-articles (flags)
   (let (new)
     (dolist (elem flags)
-      (when (or (null (cdr elem))
-		(and (not (memq '%Deleted (cdr elem)))
-		     (not (memq '%Seen (cdr elem)))))
+      (unless (gnus-list-memq-of-list nnimap-unsplittable-articles
+				      (cdr elem))
 	(push (car elem) new)))
     (gnus-compress-sequence (nreverse new))))
 
--- a/lisp/gnus/nnir.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/nnir.el	Mon Nov 08 14:19:54 2010 +0900
@@ -32,163 +32,41 @@
 
 ;; TODO: Documentation in the Gnus manual
 
-;; From: Reiner Steib
-;; Subject: Re: Including nnir.el
-;; Newsgroups: gmane.emacs.gnus.general
-;; Message-ID: <v9d5dnp6aq.fsf@marauder.physik.uni-ulm.de>
-;; Date: 2006-06-05 22:49:01 GMT
-;;
-;; On Sun, Jun 04 2006, Sascha Wilde wrote:
-;;
-;; > The one thing most hackers like to forget: Documentation.  By now the
-;; > documentation is only in the comments at the head of the source, I
-;; > would use it as basis to cook up some minimal texinfo docs.
-;; >
-;; > Where in the existing gnus manual would this fit best?
+;; Where in the existing gnus manual would this fit best?
 
-;; Maybe (info "(gnus)Combined Groups") for a general description.
-;; `gnus-group-make-nnir-group' might be described in (info
-;; "(gnus)Foreign Groups") as well.
-
-
-;; The most recent version of this can always be fetched from the Gnus
-;; repository.  See http://www.gnus.org/ for more information.
-
-;; This code is still in the development stage but I'd like other
-;; people to have a look at it.  Please do not hesitate to contact me
-;; with your ideas.
-
-;; What does it do?  Well, it allows you to index your mail using some
-;; search engine (freeWAIS-sf, swish-e and others -- see later),
-;; then type `G G' in the Group buffer and issue a query to the search
-;; engine.  You will then get a buffer which shows all articles
-;; matching the query, sorted by Retrieval Status Value (score).
+;; What does it do?  Well, it allows you to search your mail using
+;; some search engine (imap, namazu, swish-e, gmane and others -- see
+;; later) by typing `G G' in the Group buffer.  You will then get a
+;; buffer which shows all articles matching the query, sorted by
+;; Retrieval Status Value (score).
 
 ;; When looking at the retrieval result (in the Summary buffer) you
-;; can type `G T' (aka M-x gnus-summary-nnir-goto-thread RET) on an
-;; article.  You will be teleported into the group this article came
-;; from, showing the thread this article is part of.  (See below for
-;; restrictions.)
-
-;; The Lisp installation is simple: just put this file on your
-;; load-path, byte-compile it, and load it from ~/.gnus or something.
-;; This will install a new command `G G' in your Group buffer for
-;; searching your mail.  Note that you also need to configure a number
-;; of variables, as described below.
+;; can type `A W' (aka M-x gnus-warp-article RET) on an article.  You
+;; will be warped into the group this article came from. Typing `A W'
+;; (aka M-x gnus-summary-refer-thread RET) will warp to the group and
+;; also show the thread this article is part of.
 
-;; Restrictions:
-;;
-;; * If you don't use HyREX as your search engine, this expects that
-;;   you use nnml or another one-file-per-message backend, because the
-;;   others doesn't support nnfolder.
-;; * It can only search the mail backend's which are supported by one
-;;   search engine, because of different query languages.
-;; * There are restrictions to the Wais setup.
-;; * There are restrictions to the imap setup.
-;; * gnus-summary-nnir-goto-thread: Fetches whole group first, before
-;;   limiting to the right articles.  This is much too slow, of
-;;   course.  May issue a query for number of articles to fetch; you
-;;   must accept the default of all articles at this point or things
-;;   may break.
-
-;; The Lisp setup involves setting a few variables and setting up the
+;; The Lisp setup may involve setting a few variables and setting up the
 ;; search engine. You can define the variables in the server definition
 ;; like this :
 ;;   (setq gnus-secondary-select-methods '(
 ;;       (nnimap "" (nnimap-address "localhost")
-;;                  (nnir-search-engine hyrex)
-;;                  (nnir-hyrex-additional-switches ("-d" "ddl-nnimap.xml"))
+;;                  (nnir-search-engine namazu)
 ;;       )))
-;; Or you can define the global ones. The variables set in the mailer-
-;; definition will be used first.
-;; The variable to set is `nnir-search-engine'.  Choose one of the engines
-;; listed in `nnir-engines'.  (Actually `nnir-engines' is an alist,
-;; type `C-h v nnir-engines RET' for more information; this includes
-;; examples for setting `nnir-search-engine', too.)
-;;
-;; The variable nnir-mail-backend isn't used anymore.
-;;
-
-;; You must also set up a search engine.  I'll tell you about the two
-;; search engines currently supported:
+;; The main variable to set is `nnir-search-engine'.  Choose one of
+;; the engines listed in `nnir-engines'.  (Actually `nnir-engines' is
+;; an alist, type `C-h v nnir-engines RET' for more information; this
+;; includes examples for setting `nnir-search-engine', too.)
 
-;; 1. freeWAIS-sf
-;;
-;; As always with freeWAIS-sf, you need a so-called `format file'.  I
-;; use the following file:
-;;
-;; ,-----
-;; | # Kai's format file for freeWAIS-sf for indexing mails.
-;; | # Each mail is in a file, much like the MH format.
-;; |
-;; | # Document separator should never match -- each file is a document.
-;; | record-sep: /^@this regex should never match@$/
-;; |
-;; | # Searchable fields specification.
-;; |
-;; | region: /^[sS]ubject:/ /^[sS]ubject: */
-;; |         subject "Subject header" stemming TEXT BOTH
-;; | end: /^[^ \t]/
-;; |
-;; | region: /^([tT][oO]|[cC][cC]):/ /^([tT][oO]|[cC][cC]): */
-;; |         to "To and Cc headers" SOUNDEX BOTH
-;; | end: /^[^ \t]/
-;; |
-;; | region: /^[fF][rR][oO][mM]:/ /^[fF][rR][oO][mM]: */
-;; |         from "From header" SOUNDEX BOTH
-;; | end: /^[^ \t]/
-;; |
-;; | region: /^$/
-;; |         stemming TEXT GLOBAL
-;; | end: /^@this regex should never match@$/
-;; `-----
-;;
-;; 1998-07-22: waisindex would dump core on me for large articles with
-;; the above settings.  I used /^$/ as the end regex for the global
-;; field.  That seemed to work okay.
+;; If you use one of the local indices (namazu, find-grep, swish) you
+;; must also set up a search engine backend.
 
-;; There is a Perl module called `WAIS.pm' which is available from
-;; CPAN as well as ls6-ftp.cs.uni-dortmund.de:/pub/wais/Perl.  This
-;; module comes with a nifty tool called `makedb', which I use for
-;; indexing.  Here's my `makedb.conf':
-;;
-;; ,-----
-;; | # Config file for makedb
-;; |
-;; | # Global options
-;; | waisindex = /usr/local/bin/waisindex
-;; | wais_opt  = -stem -t fields
-;; | # `-stem' option necessary when `stemming' is specified for the
-;; | # global field in the *.fmt file
-;; |
-;; | # Own variables
-;; | homedir = /home/kai
-;; |
-;; | # The mail database.
-;; | database        = mail
-;; | files           = `find $homedir/Mail -name \*[0-9] -print`
-;; | dbdir           = $homedir/.wais
-;; | limit           = 100
-;; `-----
-;;
-;; The Lisp setup involves the `nnir-wais-*' variables.  The most
-;; difficult to understand variable is probably
-;; `nnir-wais-remove-prefix'.  Here's what it does: the output of
-;; `waissearch' basically contains the file name and the (full)
-;; directory name.  As Gnus works with group names rather than
-;; directory names, the directory name is transformed into a group
-;; name as follows: first, a prefix is removed from the (full)
-;; directory name, then all `/' are replaced with `.'.  The variable
-;; `nnir-wais-remove-prefix' should contain a regex matching exactly
-;; this prefix.  It defaults to `$HOME/Mail/' (note the trailing
-;; slash).
-
-;; 2. Namazu
+;; 1. Namazu
 ;;
 ;; The Namazu backend requires you to have one directory containing all
 ;; index files, this is controlled by the `nnir-namazu-index-directory'
 ;; variable.  To function the `nnir-namazu-remove-prefix' variable must
-;; also be correct, see the documentation for `nnir-wais-remove-prefix'
+;; also be correct, see the documentation for `nnir-namazu-remove-prefix'
 ;; above.
 ;;
 ;; It is particularly important not to pass any any switches to namazu
@@ -227,18 +105,7 @@
 ;; For maximum searching efficiency I have a cron job set to run this
 ;; command every four hours.
 
-;; 3. HyREX
-;;
-;; The HyREX backend requires you to have one directory from where all
-;; your relative paths are to, if you use them. This directory must be
-;; set in the `nnir-hyrex-index-directory' variable, which defaults to
-;; your home directory. You must also pass the base, class and
-;; directory options or simply your dll to the `nnir-hyrex-programm' by
-;; setting the `nnir-hyrex-additional-switches' variable accordently.
-;; To function the `nnir-hyrex-remove-prefix' variable must also be
-;; correct, see the documentation for `nnir-wais-remove-prefix' above.
-
-;; 4. find-grep
+;; 2. find-grep
 ;;
 ;; The find-grep engine simply runs find(1) to locate eligible
 ;; articles and searches them with grep(1).  This, of course, is much
@@ -294,43 +161,14 @@
 ;; function should return the list of articles as a vector, as
 ;; described above.  Then, you need to register this backend in
 ;; `nnir-engines'.  Then, users can choose the backend by setting
-;; `nnir-search-engine'.
-
-;; Todo, or future ideas:
-
-;; * It should be possible to restrict search to certain groups.
-;;
-;; * There is currently no error checking.
-;;
-;; * The summary buffer display is currently really ugly, with all the
-;;   added information in the subjects.  How could I make this
-;;   prettier?
-;;
-;; * A function which can be called from an nnir summary buffer which
-;;   teleports you into the group the current article came from and
-;;   shows you the whole thread this article is part of.
-;;   Implementation suggestions?
-;;   (1998-07-24: There is now a preliminary implementation, but
-;;   it is much too slow and quite fragile.)
-;;
-;; * Support other mail backends.  In particular, probably quite a few
-;;   people use nnfolder.  How would one go about searching nnfolders
-;;   and producing the right data needed?  The group name and the RSV
-;;   are simple, but what about the article number?
-;;   - The article number is encoded in the `X-Gnus-Article-Number'
-;;     header of each mail.
-;;   - The HyREX engine supports nnfolder.
-;;
-;; * Support compressed mail files.  Probably, just stripping off the
-;;   `.gz' or `.Z' file name extension is sufficient.
-;;
-;; * At least for imap, the query is performed twice.
-;;
-
-;; Have you got other ideas?
+;; `nnir-search-engine' as a server variable.
 
 ;;; Setup Code:
 
+;; For Emacs <22.2 and XEmacs.
+(eval-and-compile
+  (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
+
 (require 'nnoo)
 (require 'gnus-group)
 (require 'gnus-sum)
@@ -350,143 +188,27 @@
 
 (gnus-declare-backend "nnir" 'mail)
 
-(defvar nnir-imap-default-search-key "Whole message"
-  "The default IMAP search key for an nnir search. Must be one of
-  the keys in nnir-imap-search-arguments. To use raw imap queries
-  by default set this to \"Imap\"")
-
-(defvar nnir-imap-search-arguments
-  '(("Whole message" . "TEXT")
-    ("Subject" . "SUBJECT")
-    ("To" . "TO")
-    ("From" . "FROM")
-    ("Imap" . ""))
-  "Mapping from user readable keys to IMAP search items for use in nnir")
-
-(defvar nnir-imap-search-other "HEADER %S"
-  "The IMAP search item to use for anything other than
-  nnir-imap-search-arguments. By default this is the name of an
-  email header field")
-
-(defvar nnir-imap-search-argument-history ()
-  "The history for querying search options in nnir")
-
-(defvar nnir-get-article-nov-override-function nil
-  "If non-nil, a function that will be passed each search result.  This
-should return a message's headers in NOV format.
-
-If this variable is nil, or if the provided function returns nil for a search
-result, `gnus-retrieve-headers' will be called instead.")
-
-
-;;; Developer Extension Variable:
-
-(defvar nnir-engines
-  `((wais    nnir-run-waissearch
-             ())
-    (imap    nnir-run-imap
-             ((criteria
-	       "Search in"                        ; Prompt
-	       ,(mapcar 'car nnir-imap-search-arguments) ; alist for completing
-	       nil                                ; allow any user input
-	       nil                                ; initial value
-	       nnir-imap-search-argument-history  ; the history to use
-	       ,nnir-imap-default-search-key      ; default
-	       )))
-    (swish++ nnir-run-swish++
-             ((group . "Group spec: ")))
-    (swish-e nnir-run-swish-e
-             ((group . "Group spec: ")))
-    (namazu  nnir-run-namazu
-             ())
-    (hyrex   nnir-run-hyrex
-	     ((group . "Group spec: ")))
-  (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
-a symbol, giving the function that does the search.  The third element
-ARGS is a list of cons pairs (PARAM . PROMPT).  When issuing a query,
-the FUNCTION will issue a query for each of the PARAMs, using PROMPT.
-
-The value of `nnir-search-engine' must be one of the ENGINE symbols.
-For example, use the following line for searching using freeWAIS-sf:
-    (setq nnir-search-engine 'wais)
-Use the following line if you read your mail via IMAP and your IMAP
-server supports searching:
-    (setq nnir-search-engine 'imap)
-Note that you have to set additional variables for most backends.  For
-example, the `wais' backend needs the variables `nnir-wais-program',
-`nnir-wais-database' and `nnir-wais-remove-prefix'.
-
-Add an entry here when adding a new search engine.")
 
 ;;; User Customizable Variables:
 
 (defgroup nnir nil
-  "Search nnmh and nnml groups in Gnus with swish-e, freeWAIS-sf, or EWS."
+  "Search groups in Gnus with assorted seach engines."
   :group 'gnus)
 
-;; Mail backend.
-
-;; TODO:
-;; If `nil', use server parameters to find out which server to search. CCC
-;;
-(defcustom nnir-mail-backend '(nnml "")
-  "*Specifies which backend should be searched.
-More precisely, this is used to determine from which backend to fetch the
-messages found.
-
-This must be equal to an existing server, so maybe it is best to use
-something like the following:
-    (setq nnir-mail-backend (nth 0 gnus-secondary-select-methods))
-The above line works fine if the mail backend you want to search is
-the first element of gnus-secondary-select-methods (`nth' starts counting
-at zero)."
-  :type '(sexp)
+(defcustom nnir-method-default-engines
+  '((nnimap . imap)
+    (nntp . gmane))
+  "*Alist of default search engines keyed by server method"
+  :type '(alist)
   :group 'nnir)
 
-;; Search engine to use.
-
-(defcustom nnir-search-engine 'wais
-  "*The search engine to use.  Must be a symbol.
-See `nnir-engines' for a list of supported engines, and for example
-settings of `nnir-search-engine'."
-  :type '(sexp)
-  :group 'nnir)
-
-;; freeWAIS-sf.
-
-(defcustom nnir-wais-program "waissearch"
-  "*Name of waissearch executable."
+(defcustom nnir-imap-default-search-key "Whole message"
+  "*The default IMAP search key for an nnir search. Must be one of
+  the keys in `nnir-imap-search-arguments'. To use raw imap queries
+  by default set this to \"Imap\""
   :type '(string)
   :group 'nnir)
 
-(defcustom nnir-wais-database (expand-file-name "~/.wais/mail")
-  "*Name of Wais database containing the mail.
-
-Note that this should be a file name without extension.  For example,
-if you have a file /home/john/.wais/mail.fmt, use this:
-    (setq nnir-wais-database \"/home/john/.wais/mail\")
-The string given here is passed to `waissearch -d' as-is."
-  :type '(file)
-  :group 'nnir)
-
-(defcustom nnir-wais-remove-prefix (concat (getenv "HOME") "/Mail/")
-  "*The prefix to remove from each directory name returned by waissearch
-in order to get a group name (albeit with / instead of .).  This is a
-regular expression.
-
-For example, suppose that Wais returns file names such as
-\"/home/john/Mail/mail/misc/42\".  For this example, use the following
-setting:  (setq nnir-wais-remove-prefix \"/home/john/Mail/\")
-Note the trailing slash.  Removing this prefix gives \"mail/misc/42\".
-`nnir' knows to remove the \"/42\" and to replace \"/\" with \".\" to
-arrive at the correct group name, \"mail.misc\"."
-  :type '(regexp)
-  :group 'nnir)
-
 (defcustom nnir-swish++-configuration-file
   (expand-file-name "~/Mail/swish++.conf")
   "*Configuration file for swish++."
@@ -513,8 +235,8 @@
 in order to get a group name (albeit with / instead of .).  This is a
 regular expression.
 
-This variable is very similar to `nnir-wais-remove-prefix', except
-that it is for swish++, not Wais."
+This variable is very similar to `nnir-namazu-remove-prefix', except
+that it is for swish++, not Namazu."
   :type '(regexp)
   :group 'nnir)
 
@@ -564,8 +286,8 @@
 in order to get a group name (albeit with / instead of .).  This is a
 regular expression.
 
-This variable is very similar to `nnir-wais-remove-prefix', except
-that it is for swish-e, not Wais.
+This variable is very similar to `nnir-namazu-remove-prefix', except
+that it is for swish-e, not Namazu.
 
 This could be a server parameter."
   :type '(regexp)
@@ -633,11 +355,81 @@
   "*The prefix to remove from each file name returned by Namazu
 in order to get a group name (albeit with / instead of .).
 
-This variable is very similar to `nnir-wais-remove-prefix', except
-that it is for Namazu, not Wais."
+For example, suppose that Namazu returns file names such as
+\"/home/john/Mail/mail/misc/42\".  For this example, use the following
+setting:  (setq nnir-namazu-remove-prefix \"/home/john/Mail/\")
+Note the trailing slash.  Removing this prefix gives \"mail/misc/42\".
+`nnir' knows to remove the \"/42\" and to replace \"/\" with \".\" to
+arrive at the correct group name, \"mail.misc\"."
   :type '(directory)
   :group 'nnir)
 
+;; Imap variables
+
+(defvar nnir-imap-search-arguments
+  '(("Whole message" . "TEXT")
+    ("Subject" . "SUBJECT")
+    ("To" . "TO")
+    ("From" . "FROM")
+    ("Imap" . ""))
+  "Mapping from user readable keys to IMAP search items for use in nnir")
+
+(defvar nnir-imap-search-other "HEADER %S"
+  "The IMAP search item to use for anything other than
+  `nnir-imap-search-arguments'. By default this is the name of an
+  email header field")
+
+(defvar nnir-imap-search-argument-history ()
+  "The history for querying search options in nnir")
+
+;;; Developer Extension Variable:
+
+(defvar nnir-engines
+  `((imap    nnir-run-imap
+             ((criteria
+	       "Imap Search in"                   ; Prompt
+	       ,(mapcar 'car nnir-imap-search-arguments) ; alist for completing
+	       nil                                ; allow any user input
+	       nil                                ; initial value
+	       nnir-imap-search-argument-history  ; the history to use
+	       ,nnir-imap-default-search-key      ; default
+	       )))
+    (gmane   nnir-run-gmane
+	     ((author . "Gmane Author: ")))
+    (swish++ nnir-run-swish++
+             ((group . "Swish++ Group spec: ")))
+    (swish-e nnir-run-swish-e
+             ((group . "Swish-e Group spec: ")))
+    (namazu  nnir-run-namazu
+             ())
+    (hyrex   nnir-run-hyrex
+	     ((group . "Hyrex Group spec: ")))
+    (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
+a symbol, giving the function that does the search.  The third element
+ARGS is a list of cons pairs (PARAM . PROMPT).  When issuing a query,
+the FUNCTION will issue a query for each of the PARAMs, using PROMPT.
+
+The value of `nnir-search-engine' must be one of the ENGINE symbols.
+For example, for searching a server using namazu include
+    (nnir-search-engine namazu)
+in the server definition.  Note that you have to set additional
+variables for most backends.  For example, the `namazu' backend
+needs the variables `nnir-namazu-program',
+`nnir-namazu-index-directory' and `nnir-namazu-remove-prefix'.
+
+Add an entry here when adding a new search engine.")
+
+(defvar nnir-get-article-nov-override-function nil
+  "If non-nil, a function that will be passed each search result.  This
+should return a message's headers in NOV format.
+
+If this variable is nil, or if the provided function returns nil for a search
+result, `gnus-retrieve-headers' will be called instead.")
+
 ;;; Internal Variables:
 
 (defvar nnir-current-query nil
@@ -655,99 +447,33 @@
 (defvar nnir-tmp-buffer " *nnir*"
   "Internal: temporary buffer.")
 
+(defvar nnir-search-history ()
+  "Internal: the history for querying search options in nnir")
+
+(defvar nnir-extra-parms nil
+  "Internal: stores request for extra search parms")
+
 ;;; Code:
 
 ;; Gnus glue.
 
-(defun gnus-group-make-nnir-group (extra-parms query)
+(defun gnus-group-make-nnir-group (nnir-extra-parms)
   "Create an nnir group.  Asks for query."
-  (interactive "P\nsQuery: ")
+  (interactive "P")
   (setq nnir-current-query nil
 	nnir-current-server nil
 	nnir-current-group-marked nil
 	nnir-artlist nil)
-  (let ((parms nil))
-    (if extra-parms
-        (setq parms (nnir-read-parms query))
-      (setq parms (list (cons 'query query))))
+  (let* ((query (read-string "Query: " nil 'nnir-search-history))
+	 (parms (list (cons 'query query)))
+	 (srv (if (gnus-server-server-name)
+		  "all"	"")))
     (add-to-list 'parms (cons 'unique-id (message-unique-id)) t)
     (gnus-group-read-ephemeral-group
-     (concat "nnir:" (prin1-to-string parms)) '(nnir "") t
-     (cons (current-buffer)
-           gnus-current-window-configuration)
+     (concat "nnir:" (prin1-to-string parms)) (list 'nnir srv) t
+     (cons (current-buffer) 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)
-  "Return the server for a newsgroup GROUP.
-The returned format is as `gnus-server-to-method' needs it.  See
-`gnus-group-real-prefix' and `gnus-group-real-name'."
-  `(let ((gname ,group))
-     (if (string-match "^\\([^:]+\\):" gname)
-	 (progn
-	   (setq gname (match-string 1 gname))
-	   (if (string-match "^\\([^+]+\\)\\+\\(.+\\)$" gname)
-	       (format "%s:%s" (match-string 1 gname) (match-string 2 gname))
-	     (concat gname ":")))
-       (format "%s:%s" (car gnus-select-method) (cadr gnus-select-method)))))
-
-;; Summary mode commands.
-
-(defun gnus-summary-nnir-goto-thread ()
-  "Only applies to nnir groups.  Go to group this article came from
-and show thread that contains this article."
-  (interactive)
-  (unless (eq 'nnir (car (gnus-find-method-for-group gnus-newsgroup-name)))
-    (error "Can't execute this command unless in nnir group"))
-  (let* ((cur (gnus-summary-article-number))
-         (group (nnir-artlist-artitem-group nnir-artlist cur))
-         (backend-number (nnir-artlist-artitem-number nnir-artlist cur))
-	 (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)))))))))
-      (gnus-summary-read-group-1 group t t gnus-summary-buffer
-				 nil (list backend-number))
-      (gnus-summary-limit (list backend-number))
-      (gnus-summary-refer-thread))))
-
-
-(if (fboundp 'eval-after-load)
-    (eval-after-load "gnus-sum"
-      '(define-key gnus-summary-goto-map
-         "T" 'gnus-summary-nnir-goto-thread))
-  (add-hook 'gnus-summary-mode-hook
-            (function (lambda ()
-                        (define-key gnus-summary-goto-map
-                          "T" 'gnus-summary-nnir-goto-thread)))))
-
-
 
 ;; Gnus backend interface functions.
 
@@ -765,24 +491,19 @@
                (equal server nnir-current-server)))
       nnir-artlist
     ;; Cache miss.
-    (setq nnir-artlist (nnir-run-query group)))
+    (setq nnir-artlist (nnir-run-query group server)))
   (with-current-buffer nntp-server-buffer
+    (setq nnir-current-query group)
+    (when server (setq nnir-current-server server))
+    (setq nnir-current-group-marked gnus-group-marked)
     (if (zerop (length nnir-artlist))
-	(progn
-	  (setq nnir-current-query nil
-		nnir-current-server nil
-		nnir-current-group-marked nil
-		nnir-artlist nil)
-	  (nnheader-report 'nnir "Search produced empty results."))
+	(nnheader-report 'nnir "Search produced empty results.")
       ;; Remember data for cache.
-      (setq nnir-current-query group)
-      (when server (setq nnir-current-server server))
-      (setq nnir-current-group-marked gnus-group-marked)
       (nnheader-insert "211 %d %d %d %s\n"
 		       (nnir-artlist-length nnir-artlist) ; total #
 		       1              ; first #
 		       (nnir-artlist-length nnir-artlist) ; last #
-		       group))))     ; group name
+		       group))))      ; group name
 
 (deffoo nnir-retrieve-headers (articles &optional group server fetch-old)
   (save-excursion
@@ -801,7 +522,7 @@
         (setq artfullgroup (nnir-artitem-group artitem))
         (setq artno (nnir-artitem-number artitem))
         (setq artgroup (gnus-group-real-name artfullgroup))
-	(setq server (nnir-group-server artfullgroup))
+	(setq server (gnus-group-server artfullgroup))
         ;; retrieve NOV or HEAD data for this article, transform into
         ;; NOV data and prepend to `novdata'
         (set-buffer nntp-server-buffer)
@@ -865,6 +586,33 @@
 	(gnus-request-article artno artfullgroup nntp-server-buffer)
 	(cons artfullgroup artno)))))
 
+(deffoo nnir-request-move-article (article group server accept-form
+					   &optional last internal-move-group)
+  (let* ((artitem (nnir-artlist-article nnir-artlist
+					article))
+	 (artfullgroup (nnir-artitem-group artitem))
+	 (artno (nnir-artitem-number artitem))
+	 (to-newsgroup (nth 1 accept-form))
+	 (to-method (gnus-find-method-for-group to-newsgroup))
+	 (from-method (gnus-find-method-for-group artfullgroup))
+	 (move-is-internal (gnus-server-equal from-method to-method)))
+    (gnus-request-move-article
+     artno
+     artfullgroup
+     (nth 1 from-method)
+     accept-form
+     last
+     (and move-is-internal
+	  to-newsgroup		; Not respooling
+	  (gnus-group-real-name to-newsgroup))) ; Is this move internal
+    ))
+
+(deffoo nnir-warp-to-article ()
+  (let* ((cur (gnus-summary-article-number))
+         (gnus-newsgroup-name (nnir-artlist-artitem-group nnir-artlist cur))
+         (backend-number (nnir-artlist-artitem-number nnir-artlist cur)))
+    (gnus-summary-read-group-1 gnus-newsgroup-name t t gnus-summary-buffer
+			       nil (list backend-number))))
 
 (nnoo-define-skeleton nnir)
 
@@ -911,94 +659,50 @@
 
 ;;; Search Engine Interfaces:
 
-;; freeWAIS-sf interface.
-(defun nnir-run-waissearch (query server &optional group)
-  "Run given query agains waissearch.  Returns vector of (group name, file name)
-pairs (also vectors, actually)."
-  (when group
-    (error "The freeWAIS-sf backend cannot search specific groups"))
-  (save-excursion
-    (let ((qstring (cdr (assq 'query query)))
-	  (prefix (nnir-read-server-parm 'nnir-wais-remove-prefix server))
-          artlist score artno dirnam)
-      (set-buffer (get-buffer-create nnir-tmp-buffer))
-      (erase-buffer)
-      (message "Doing WAIS query %s..." query)
-      (call-process nnir-wais-program
-                    nil                 ; input from /dev/null
-                    t                   ; output to current buffer
-                    nil                 ; don't redisplay
-                    "-d" (nnir-read-server-parm 'nnir-wais-database server) ; database to search
-                    qstring)
-      (message "Massaging waissearch output...")
-      ;; remove superfluous lines
-      (keep-lines "Score:")
-      ;; extract data from result lines
-      (goto-char (point-min))
-      (while (re-search-forward
-              "Score: +\\([0-9]+\\).*'\\([0-9]+\\) +\\([^']+\\)/'" nil t)
-        (setq score (match-string 1)
-              artno (match-string 2)
-              dirnam (match-string 3))
-        (unless (string-match prefix dirnam)
-          (nnheader-report 'nnir "Dir name %s doesn't contain prefix %s"
-                           dirnam prefix))
-        (setq group (gnus-replace-in-string
-                     (replace-match "" t t dirnam) "/" "."))
-        (push (vector (nnir-group-full-name group server)
-                      (string-to-number artno)
-                      (string-to-number score))
-              artlist))
-      (message "Massaging waissearch output...done")
-      (apply 'vector
-             (sort artlist
-                   (function (lambda (x y)
-                               (> (nnir-artitem-rsv x)
-                                  (nnir-artitem-rsv y)))))))))
-
-;; IMAP interface.
-;; todo:
-;; send queries as literals
-;; handle errors
-
-
-(defun nnir-run-imap (query srv &optional group-option)
+;; imap interface
+(defun nnir-run-imap (query srv &optional groups)
   "Run a search against an IMAP back-end server.
 This uses a custom query language parser; see `nnir-imap-make-query' for
 details on the language and supported extensions"
   (save-excursion
     (let ((qstring (cdr (assq 'query query)))
-	  (server (cadr (gnus-server-to-method srv)))
-	  (group (or group-option (gnus-group-group-name)))
-	  (defs (caddr (gnus-server-to-method srv)))
-	  (criteria (or (cdr (assq 'criteria query))
-			(cdr (assoc nnir-imap-default-search-key
-				    nnir-imap-search-arguments))))
-	  (gnus-inhibit-demon t)
-	  artlist)
+          (server (cadr (gnus-server-to-method srv)))
+          (defs (caddr (gnus-server-to-method srv)))
+          (criteria (or (cdr (assq 'criteria query))
+                        (cdr (assoc nnir-imap-default-search-key
+                                    nnir-imap-search-arguments))))
+          (gnus-inhibit-demon t)
+	  (groups (or groups (nnir-get-active srv)))
+          artlist)
       (message "Opening server %s" server)
-      (condition-case ()
-	  (when (nnimap-possibly-change-group (gnus-group-short-name group) server)
-	    (with-current-buffer (nnimap-buffer)
-	      (message "Searching %s..." group)
-	      (let ((arts 0)
-		    (result
-		     (nnimap-command "UID SEARCH %s"
-				     (if (string= criteria "")
-					 qstring
-				       (nnir-imap-make-query criteria qstring)
-				       ))))
-		(mapc
-		 (lambda (artnum)
-		   (push (vector group artnum 1) artlist)
-		   (setq arts (1+ arts)))
-		 (and (car result)
-		      (delete 0 (mapcar #'string-to-number
-					(cdr (assoc "SEARCH" (cdr result)))))))
-		(message "Searching %s... %d matches" group arts)))
-	    (message "Searching %s...done" group))
-	(quit nil))
-      (reverse artlist))))
+      (apply
+       'vconcat
+       (mapcar
+	(lambda (x)
+	  (let ((group x))
+	    (condition-case ()
+		(when (nnimap-possibly-change-group
+		       (gnus-group-short-name group) server)
+		  (with-current-buffer (nnimap-buffer)
+		    (message "Searching %s..." group)
+		    (let ((arts 0)
+			  (result (nnimap-command "UID SEARCH %s"
+						  (if (string= criteria "")
+						      qstring
+						    (nnir-imap-make-query
+						     criteria qstring)))))
+		      (mapc
+		       (lambda (artnum) (push (vector group artnum 1) artlist)
+			 (setq arts (1+ arts)))
+		       (and (car result)
+			    (delete 0 (mapcar #'string-to-number
+					      (cdr (assoc "SEARCH"
+							  (cdr result)))))))
+		      (message "Searching %s... %d matches" group arts)))
+		  (message "Searching %s...done" group))
+	      (quit nil))
+	    (reverse artlist)))
+	groups)))))
 
 (defun nnir-imap-make-query (criteria qstring)
   "Parse the query string and criteria into an appropriate IMAP search
@@ -1188,8 +892,8 @@
 Tested with swish++ 4.7 on GNU/Linux and with swish++ 5.0b2 on
 Windows NT 4.0."
 
-  (when group
-    (error "The swish++ backend cannot search specific groups"))
+  ;; (when group
+  ;;   (error "The swish++ backend cannot search specific groups"))
 
   (save-excursion
     (let ( (qstring (cdr (assq 'query query)))
@@ -1277,8 +981,8 @@
 Tested with swish-e-2.0.1 on Windows NT 4.0."
 
   ;; swish-e crashes with empty parameter to "-w" on commandline...
-  (when group
-    (error "The swish-e backend cannot search specific groups"))
+  ;; (when group
+  ;;   (error "The swish-e backend cannot search specific groups"))
 
   (save-excursion
     (let ((qstring (cdr (assq 'query query)))
@@ -1370,19 +1074,13 @@
           (qstring (cdr (assq 'query query)))
 	  (prefix (nnir-read-server-parm 'nnir-hyrex-remove-prefix server))
 	  score artno dirnam)
-      (when (and group groupspec)
-        (error (concat "It does not make sense to use a group spec"
-                       " with process-marked groups.")))
-      (when group
-        (setq groupspec (gnus-group-real-name group)))
-      (when (and group (not (equal group (nnir-group-full-name groupspec server))))
-	(message "%s vs. %s" group (nnir-group-full-name groupspec server))
-	(error "Server with groupspec doesn't match group !"))
+      (when (and (not groupspec) group)
+        (setq groupspec
+	      (regexp-opt
+	       (mapcar (lambda (x) (gnus-group-real-name x)) group))))
       (set-buffer (get-buffer-create nnir-tmp-buffer))
       (erase-buffer)
-      (if groupspec
-          (message "Doing hyrex-search query %s on %s..." query groupspec)
-        (message "Doing hyrex-search query %s..." query))
+      (message "Doing hyrex-search query %s..." query)
       (let* ((cp-list
 	      `( ,nnir-hyrex-program
 		 nil			; input from /dev/null
@@ -1404,16 +1102,14 @@
           ;; the user wants it.
           (when (> gnus-verbose 6)
             (display-buffer nnir-tmp-buffer)))) ;; FIXME: Dont clear buffer !
-      (if groupspec
-          (message "Doing hyrex-search query \"%s\" on %s...done" qstring groupspec)
-        (message "Doing hyrex-search query \"%s\"...done" qstring))
+      (message "Doing hyrex-search query \"%s\"...done" qstring)
       (sit-for 0)
       ;; nnir-search returns:
       ;;   for nnml/nnfolder: "filename mailid weigth"
       ;;   for nnimap:        "group mailid weigth"
       (goto-char (point-min))
       (delete-non-matching-lines "^\\S + [0-9]+ [0-9]+$")
-      ;; HyREX couldn't search directly in groups -- so filter out here.
+      ;; HyREX doesn't search directly in groups -- so filter out here.
       (when groupspec
 	(keep-lines groupspec))
       ;; extract data from result lines
@@ -1447,8 +1143,8 @@
 pairs (also vectors, actually).
 
 Tested with Namazu 2.0.6 on a GNU/Linux system."
-  (when group
-    (error "The Namazu backend cannot search specific groups"))
+  ;; (when group
+  ;;   (error "The Namazu backend cannot search specific groups"))
   (save-excursion
     (let ((article-pattern (if (string= (gnus-group-server server) "nnmaildir")
 			       ":[0-9]+"
@@ -1510,7 +1206,7 @@
                                (> (nnir-artitem-rsv x)
                                   (nnir-artitem-rsv y)))))))))
 
-(defun nnir-run-find-grep (query server &optional group)
+(defun nnir-run-find-grep (query server &optional grouplist)
   "Run find and grep to obtain matching articles."
   (let* ((method (gnus-server-to-method server))
 	 (sym (intern
@@ -1522,65 +1218,141 @@
     (unless directory
       (error "No directory found in method specification of server %s"
 	     server))
-    (message "Searching %s using find-grep..." (or group server))
-    (save-window-excursion
-      (set-buffer (get-buffer-create nnir-tmp-buffer))
-      (erase-buffer)
-      (if (> gnus-verbose 6)
-	  (pop-to-buffer (current-buffer)))
-      (cd directory) ; Using relative paths simplifies postprocessing.
-      (let ((group
-	     (if (not group)
-		 "."
-	       ;; Try accessing the group literally as well as
-	       ;; interpreting dots as directory separators so the
-	       ;; engine works with plain nnml as well as the Gnus Cache.
-               (let ((group (gnus-group-real-name group)))
-                 ;; Replace cl-func find-if.
-                 (if (file-directory-p group)
-                     group
-                   (if (file-directory-p
-                        (setq group (gnus-replace-in-string group "\\." "/" t)))
-                       group))))))
-	(unless group
-	  (error "Cannot locate directory for group"))
-	(save-excursion
-	  (apply
-	   'call-process "find" nil t
-	   "find" group "-type" "f" "-name" "[0-9]*" "-exec"
-	   "grep"
-	   `("-l" ,@(and grep-options
-			 (split-string grep-options "\\s-" t))
-	     "-e" ,regexp "{}" "+"))))
+    (apply
+     'vconcat
+     (mapcar (lambda (x)
+	       (let ((group x))
+		 (message "Searching %s using find-grep..."
+			  (or group server))
+		 (save-window-excursion
+		   (set-buffer (get-buffer-create nnir-tmp-buffer))
+		   (erase-buffer)
+		   (if (> gnus-verbose 6)
+		       (pop-to-buffer (current-buffer)))
+		   (cd directory) ; Using relative paths simplifies
+				  ; postprocessing.
+		   (let ((group
+			  (if (not group)
+			      "."
+			    ;; Try accessing the group literally as
+			    ;; well as interpreting dots as directory
+			    ;; separators so the engine works with
+			    ;; plain nnml as well as the Gnus Cache.
+			    (let ((group (gnus-group-real-name group)))
+			      ;; Replace cl-func find-if.
+			      (if (file-directory-p group)
+				  group
+				(if (file-directory-p
+				     (setq group
+					   (gnus-replace-in-string
+					    group
+					    "\\." "/" t)))
+				    group))))))
+		     (unless group
+		       (error "Cannot locate directory for group"))
+		     (save-excursion
+		       (apply
+			'call-process "find" nil t
+			"find" group "-type" "f" "-name" "[0-9]*" "-exec"
+			"grep"
+			`("-l" ,@(and grep-options
+				      (split-string grep-options "\\s-" t))
+			  "-e" ,regexp "{}" "+"))))
 
-      ;; Translate relative paths to group names.
-      (while (not (eobp))
-	(let* ((path (split-string
-		      (buffer-substring (point) (line-end-position)) "/" t))
-	       (art (string-to-number (car (last path)))))
-	  (while (string= "." (car path))
-	    (setq path (cdr path)))
-	  (let ((group (mapconcat 'identity
-                                  ;; Replace cl-func: (subseq path 0 -1)
-                                  (let ((end (1- (length path)))
-                                        res)
-                                    (while (>= (setq end (1- end)) 0)
-                                      (push (pop path) res))
-                                    (nreverse res))
-                                  ".")))
-	    (push (vector (nnir-group-full-name group server) art 0)
-		  artlist))
-	  (forward-line 1)))
-      (message "Searching %s using find-grep...done" (or group server))
-      artlist)))
+		   ;; Translate relative paths to group names.
+		   (while (not (eobp))
+		     (let* ((path (split-string
+				   (buffer-substring
+				    (point)
+				    (line-end-position)) "/" t))
+			    (art (string-to-number (car (last path)))))
+		       (while (string= "." (car path))
+			 (setq path (cdr path)))
+		       (let ((group (mapconcat 'identity
+					       ;; Replace cl-func:
+					       ;; (subseq path 0 -1)
+					       (let ((end (1- (length path)))
+						     res)
+						 (while
+						     (>= (setq end (1- end)) 0)
+						   (push (pop path) res))
+						 (nreverse res))
+					       ".")))
+			 (push
+			  (vector (nnir-group-full-name group server) art 0)
+			  artlist))
+		       (forward-line 1)))
+		   (message "Searching %s using find-grep...done"
+			    (or group server))
+		   artlist)))
+     grouplist))))
+
+(declare-function mm-url-insert "mm-url" (url &optional follow-refresh))
+(declare-function mm-url-encode-www-form-urlencoded "mm-url" (pairs))
+
+;; gmane interface
+(defun nnir-run-gmane (query srv &optional groups)
+  "Run a search against a gmane back-end server."
+  (if (gnus-string-match-p "gmane" srv)
+      (let* ((case-fold-search t)
+	     (qstring (cdr (assq 'query query)))
+	     (server (cadr (gnus-server-to-method srv)))
+	     (groupspec (if groups
+			    (mapconcat
+			     (function (lambda (x)
+					 (format "group:%s"
+						 (gnus-group-short-name x))))
+			     groups " ") ""))
+	     (authorspec
+	      (if (assq 'author query)
+		  (format "author:%s" (cdr (assq 'author query))) ""))
+	     (search (format "%s %s %s"
+			     qstring groupspec authorspec))
+	     (gnus-inhibit-demon t)
+	     artlist)
+	(require 'mm-url)
+	(with-current-buffer nntp-server-buffer
+	  (erase-buffer)
+	  (mm-url-insert
+	   (concat
+	    "http://search.gmane.org/nov.php"
+	    "?"
+	    (mm-url-encode-www-form-urlencoded
+	     `(("query" . ,search)
+	       ("HITSPERPAGE" . "999")))))
+	  (unless (featurep 'xemacs) (set-buffer-multibyte t))
+	  (mm-decode-coding-region (point-min) (point-max) 'utf-8)
+	  (goto-char (point-min))
+	  (forward-line 1)
+	  (while (not (eobp))
+	    (unless (or (eolp) (looking-at "\x0d"))
+	      (let ((header (nnheader-parse-nov)))
+		(let ((xref (mail-header-xref header))
+		      (xscore (string-to-number (cdr (assoc 'X-Score
+			       (mail-header-extra header))))))
+		  (when (string-match " \\([^:]+\\)[:/]\\([0-9]+\\)" xref)
+		    (push
+		     (vector
+		      (gnus-group-prefixed-name (match-string 1 xref) srv)
+		      (string-to-number (match-string 2 xref)) xscore)
+		     artlist)))))
+	    (forward-line 1)))
+	;; Sort by score
+	(apply 'vector
+	       (sort artlist
+		     (function (lambda (x y)
+				 (> (nnir-artitem-rsv x)
+				    (nnir-artitem-rsv y)))))))
+    (message "Can't search non-gmane nntp groups")
+    nil))
 
 ;;; Util Code:
 
-(defun nnir-read-parms (query)
+(defun nnir-read-parms (query nnir-search-engine)
   "Reads additional search parameters according to `nnir-engines'."
   (let ((parmspec (caddr (assoc nnir-search-engine nnir-engines))))
-    (cons (cons 'query query)
-          (mapcar 'nnir-read-parm parmspec))))
+    (append query
+	   (mapcar 'nnir-read-parm parmspec))))
 
 (defun nnir-read-parm (parmspec)
   "Reads a single search parameter.
@@ -1594,56 +1366,49 @@
 	  (cons sym (format (cdr mapping) result)))
       (cons sym (read-string prompt)))))
 
-(defun nnir-run-query (query)
+(defun nnir-run-query (query nserver)
   "Invoke appropriate search engine function (see `nnir-engines').
-If some groups were process-marked, run the query for each of the groups
-and concat the results."
-  (let ((q (car (read-from-string query))))
-    (if gnus-group-marked
-	(apply 'vconcat
-	       (mapcar (lambda (x)
-			 (let ((server (nnir-group-server x))
-			       search-func)
-			   (setq search-func (cadr
-					      (assoc
-					       (nnir-read-server-parm 'nnir-search-engine server) nnir-engines)))
-			   (if search-func
-			       (funcall search-func q server x)
-			     nil)))
-		       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)
-			     (setq search-func (cadr
-						(assoc
-						 (nnir-read-server-parm 'nnir-search-engine server) nnir-engines)))
-			     (if search-func
-				 (funcall search-func q server nil)
-			       nil))
-			 nil))
-		     gnus-opened-servers)
-	     ))
-    ))
+  If some groups were process-marked, run the query for each of the groups
+  and concat the results."
+  (let ((q (car (read-from-string query)))
+        (groups (if (string= "all-ephemeral" nserver)
+		    (with-current-buffer gnus-server-buffer
+		      (list (list (gnus-server-server-name))))
+		  (nnir-sort-groups-by-server
+		   (or gnus-group-marked
+		       (if (gnus-group-group-name)
+			   (list (gnus-group-group-name))
+			 (cdr (assoc (gnus-group-topic-name)
+				     gnus-topic-alist))))))))
+    (apply 'vconcat
+           (mapcar (lambda (x)
+                     (let* ((server (car x))
+                            (nnir-search-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-search-engine
+						 nnir-engines)))
+                       (if search-func
+			   (funcall search-func
+				    (if nnir-extra-parms
+					(nnir-read-parms q nnir-search-engine)
+				      q)
+				    server (cdr x))
+                         nil)))
+                   groups))))
 
 (defun nnir-read-server-parm (key server)
-  "Returns the parameter value of for the given server, where server is of
-form 'backend:name'."
+  "Returns the parameter value of key for the given server, where
+server is of form 'backend:name'."
   (let ((method (gnus-server-to-method server)))
     (cond ((and method (assq key (cddr method)))
-	   (nth 1 (assq key (cddr method))))
-	  ((and nnir-mail-backend
-		(gnus-server-equal method nnir-mail-backend))
-	   (symbol-value key))
-	  (t nil))))
-;;     (if method
-;;       (if (assq key (cddr method))
-;; 	  (nth 1 (assq key (cddr method)))
-;; 	(symbol-value key))
-;;       (symbol-value key))
-;;     ))
+    	   (nth 1 (assq key (cddr method))))
+    	  (t nil))))
 
 (defun nnir-group-full-name (shortname server)
   "For the given group name, return a full Gnus group name.
@@ -1686,8 +1451,8 @@
   (elt artitem 2))
 
 (defun nnir-artlist-artitem-rsv (artlist n)
-  "Returns from ARTLIST the Retrieval Status Value of the Nth artitem
-\(counting from 1)."
+  "Returns from ARTLIST the Retrieval Status Value of the Nth
+artitem (counting from 1)."
   (nnir-artitem-rsv (nnir-artlist-article artlist n)))
 
 ;; unused?
@@ -1702,6 +1467,38 @@
             with-dups)
     res))
 
+(defun nnir-sort-groups-by-server (groups)
+  "sorts a list of groups into an alist keyed by server"
+(if (car groups)
+  (let (value)
+    (dolist (var groups value)
+      (let ((server (gnus-group-server var)))
+	(if (assoc server value)
+	    (nconc (cdr (assoc server value)) (list var))
+	  (push (cons (gnus-group-server var) (list var)) value))))
+    value)
+  nil))
+
+(defun nnir-get-active (srv)
+  (let ((method (gnus-server-to-method srv))
+	groups)
+    (gnus-request-list method)
+    (with-current-buffer nntp-server-buffer
+      (let ((cur (current-buffer))
+	    name)
+	(goto-char (point-min))
+	(unless (string= gnus-ignored-newsgroups "")
+	  (delete-matching-lines gnus-ignored-newsgroups))
+	(while (not (eobp))
+	  (ignore-errors
+	    (push (mm-string-as-unibyte
+		   (let ((p (point)))
+		     (skip-chars-forward "^ \t\\\\")
+		     (setq name (buffer-substring (+ p 1) (- (point) 1)))
+		     (gnus-group-full-name name method)))
+		  groups))
+	  (forward-line))))
+    groups))
 
 ;; The end.
 (provide 'nnir)
--- a/lisp/gnus/nnmail.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/nnmail.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,8 @@
 ;;; nnmail.el --- mail support functions for the Gnus mail backends
 
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 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.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;; Keywords: news, mail
@@ -1347,7 +1348,7 @@
 ;;; Utility functions
 
 (declare-function gnus-activate-group "gnus-start"
-                  (group &optional scan dont-check method))
+                  (group &optional scan dont-check method dont-sub-check))
 
 (defun nnmail-do-request-post (accept-func &optional server)
   "Utility function to directly post a message to an nnmail-derived group.
--- a/lisp/gnus/nnmairix.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/nnmairix.el	Mon Nov 08 14:19:54 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)
@@ -1357,7 +1357,7 @@
 		 (not (member (car server) gnus-ephemeral-servers))
 		 (not (member (gnus-method-to-server (car server)) occ)))
 	(push
-	 (list mserver)
+	 mserver
 	 openedserver)))
     openedserver))
 
--- a/lisp/gnus/nnrss.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/nnrss.el	Mon Nov 08 14:19:54 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/nntp.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/nntp.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,8 +1,8 @@
 ;;; nntp.el --- nntp access for Gnus
 
-;; Copyright (C) 1987, 1988, 1989, 1990, 1992, 1993,
-;;   1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002,
-;;   2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1987, 1988, 1989, 1990, 1992, 1993, 1994, 1995, 1996,
+;;   1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+;;   2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;; Keywords: news
@@ -1172,7 +1172,7 @@
 reading."
   (nntp-send-command "^.*\n" "MODE READER"))
 
-(declare-function netrc-parse "netrc" (file))
+(declare-function netrc-parse "netrc" (&optional file))
 (declare-function netrc-machine "netrc"
 		  (list machine &optional port defaultport))
 (declare-function netrc-get "netrc" (alist type))
--- a/lisp/gnus/rfc2231.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/rfc2231.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/shr.el	Mon Nov 08 14:19:54 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,8 @@
 (defvar shr-inhibit-images nil)
 (defvar shr-list-mode nil)
 (defvar shr-content-cache nil)
+(defvar shr-kinsoku-shorten nil)
+(defvar shr-table-depth 0)
 
 (defvar shr-map
   (let ((map (make-sparse-keymap)))
@@ -93,6 +99,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))
 
@@ -174,7 +181,7 @@
 	    result))
     (dolist (sub dom)
       (if (stringp sub)
-	  (push (cons :text sub) result)
+	  (push (cons 'text sub) result)
 	(push (shr-transform-dom sub) result)))
     (nreverse result)))
 
@@ -187,7 +194,7 @@
 (defun shr-generic (cont)
   (dolist (sub cont)
     (cond
-     ((eq (car sub) :text)
+     ((eq (car sub) 'text)
       (shr-insert (cdr sub)))
      ((listp (cdr sub))
       (shr-descend sub)))))
@@ -201,54 +208,91 @@
    ((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)) ?>)
+			  (aref fill-find-break-point-function-table
+				(following-char)))
+		(forward-char 1)))
+	    (when (eq (following-char) ? )
+	      (forward-char 1))
+	    t)))))
 
 (defun shr-ensure-newline ()
   (unless (zerop (current-column))
@@ -277,17 +321,49 @@
     (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."
   (interactive)
   (let ((url (get-text-property (point) 'shr-url)))
+    (cond
+     ((not url)
+      (message "No link under point"))
+     ((string-match "^mailto:" url)
+      (gnus-url-mailto url))
+     (t
+      (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")
-      (browse-url url))))
+      (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)
@@ -300,16 +376,17 @@
           (let ((alt (buffer-substring start end))
 		(inhibit-read-only t))
 	    (delete-region start end)
-	    (shr-put-image data start alt))))))
+	    (goto-char start)
+	    (shr-put-image data alt))))))
   (kill-buffer (current-buffer)))
 
-(defun shr-put-image (data point alt)
-  (if (not (display-graphic-p))
-      (insert alt)
-    (let ((image (ignore-errors
-		   (shr-rescale-image data))))
-      (when image
-	(put-image image point alt)))))
+(defun shr-put-image (data alt)
+  (if (display-graphic-p)
+      (let ((image (ignore-errors
+                     (shr-rescale-image data))))
+        (when image
+	  (insert-image image (or alt "*"))))
+    (insert alt)))
 
 (defun shr-rescale-image (data)
   (if (or (not (fboundp 'imagemagick-types))
@@ -338,13 +415,17 @@
 		     image)))
       image)))
 
+;; url-cache-extract autoloads url-cache.
+(declare-function url-cache-create-filename "url-cache" (url))
+(autoload 'mm-disable-multibyte "mm-util")
+
 (defun shr-get-image-data (url)
   "Get image data for URL.
 Return a string with image data."
   (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 +436,20 @@
   (apply #'shr-fontize-cont cont types)
   (shr-ensure-paragraph))
 
+(autoload 'widget-convert-button "wid-edit")
+
+(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 +458,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 +473,104 @@
 (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-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-img (cont)
-  (when (and (> (current-column) 0)
-	     (not (eq shr-state 'image)))
-    (insert "\n"))
-  (let ((start (point-marker)))
+(defun shr-tag-object (cont)
+  (let ((start (point))
+	url)
+    (dolist (elem cont)
+      (when (eq (car elem) 'embed)
+	(setq url (or url (cdr (assq :src (cdr elem))))))
+      (when (and (eq (car elem) 'param)
+		 (equal (cdr (assq :name (cdr elem))) "movie"))
+	(setq url (or url (cdr (assq :value (cdr elem)))))))
+    (when url
+      (shr-insert " [multimedia] ")
+      (shr-urlify start url))
+    (shr-generic cont)))
+
+(defun shr-tag-video (cont)
+  (let ((image (cdr (assq :poster cont)))
+	(url (cdr (assq :src cont)))
+	(start (point)))
+    (shr-tag-img nil image)
+    (shr-urlify start url)))
+
+(defun shr-tag-img (cont &optional url)
+  (when (or url
+	    (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))))
+	  (url (or url (cdr (assq :src cont)))))
+      (let ((start (point-marker)))
+	(when (zerop (length alt))
+	  (setq alt "*"))
+	(cond
+	 ((or (member (cdr (assq :height cont)) '("0" "1"))
+	      (member (cdr (assq :width cont)) '("0" "1")))
+	  ;; Ignore zero-sized or single-pixel images.
+	  )
+	 ((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 alt))))
+	 ((or shr-inhibit-images
+	      (and shr-blocked-images
+		   (string-match shr-blocked-images url)))
+	  (setq shr-start (point))
+	  (let ((shr-state 'space))
+	    (if (> (string-width alt) 8)
+		(shr-insert (truncate-string-to-width alt 8))
+	      (shr-insert alt))))
+	 ((url-is-cached (shr-encode-url url))
+	  (shr-put-image (shr-get-image-data url) alt))
+	 (t
+	  (insert alt)
+	  (ignore-errors
+	    (url-retrieve (shr-encode-url url) 'shr-image-fetched
+			  (list (current-buffer) start (point-marker))
+			  t))))
+	(put-text-property start (point) 'keymap shr-map)
+	(put-text-property start (point) 'shr-alt alt)
+	(put-text-property start (point) 'shr-image url)
+	(put-text-property start (point) 'help-echo alt)
+	(setq shr-state 'image)))))
 
 (defun shr-tag-pre (cont)
   (let ((shr-folding-mode 'none))
@@ -506,11 +649,12 @@
 ;; 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-table-depth (1+ shr-table-depth))
+	 (shr-kinsoku-shorten t)
 	 ;; Find all suggested widths.
 	 (columns (shr-column-specs cont))
 	 ;; Compute how many characters wide each TD should be.
@@ -520,13 +664,68 @@
 	 ;; 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
   ;; model isn't strong enough to allow us to put the images actually
   ;; into the tables.
-  (dolist (elem (shr-find-elements cont 'img))
-    (shr-tag-img (cdr elem))))
+  (when (zerop shr-table-depth)
+    (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)
@@ -568,12 +767,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/sieve-manage.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/sieve-manage.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,7 @@
 ;;; sieve-manage.el --- Implementation of the managesive protocol in elisp
 
-;; 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.
 
 ;; Author: Simon Josefsson <simon@josefsson.org>
 
@@ -79,6 +79,7 @@
   (require 'password))
 
 (eval-when-compile
+  (require 'cl)				; caddr
   (require 'sasl)
   (require 'starttls))
 (autoload 'sasl-find-mechanism "sasl")
--- a/lisp/gnus/smime.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/smime.el	Mon Nov 08 14:19:54 2010 +0900
@@ -587,6 +587,9 @@
       (kill-buffer digbuf)
       retbuf))
 
+(declare-function ldap-search "ldap"
+		  (filter &optional host attributes attrsonly withdn))
+
 (defun smime-cert-by-ldap-1 (mail host)
   "Get cetificate for MAIL from the ldap server at HOST."
   (let ((ldapresult
@@ -595,7 +598,9 @@
 	      (progn
 		(require 'smime-ldap)
 		'smime-ldap-search)
-	    'ldap-search)
+	    (progn
+	      (require 'ldap)
+	      'ldap-search))
 	  (concat "mail=" mail)
 	  host '("userCertificate") nil))
 	(retbuf (generate-new-buffer (format "*certificate for %s*" mail)))
--- a/lisp/gnus/spam.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/gnus/spam.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/help-fns.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/help.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/hexl.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/image.el	Mon Nov 08 14:19:54 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/info.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/info.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,8 +1,8 @@
 ;; info.el --- info package for Emacs
 
-;; Copyright (C) 1985, 1986, 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) 1985, 1986, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
+;;   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
+;;   2010  Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: help
@@ -3379,6 +3379,8 @@
 (declare-function find-library-name "find-func" (library))
 (declare-function finder-unknown-keywords "finder" ())
 (declare-function lm-commentary "lisp-mnt" (&optional file))
+(defvar finder-keywords-hash)
+(defvar package-alist)                  ; finder requires package
 
 (defun Info-finder-find-node (filename nodename &optional no-going-back)
   "Finder-specific implementation of Info-find-node-2."
@@ -4930,5 +4932,4 @@
 
 (provide 'info)
 
-;; arch-tag: f2480fe2-2139-40c1-a49b-6314991164ac
 ;;; info.el ends here
--- a/lisp/international/ccl.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/international/ccl.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/international/characters.el	Mon Nov 08 14:19:54 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)
@@ -1231,6 +1234,131 @@
 (optimize-char-table (standard-category-table))
 
 
+;; Display of glyphless characters.
+
+(defvar char-acronym-table
+  (make-char-table 'char-acronym-table nil)
+  "Char table of acronyms for non-graphic characters.")
+
+(let ((c0-acronyms '("NUL" "SOH" "STX" "ETX" "EOT" "ENQ" "ACK" "BEL"
+		     "BS"   nil   nil  "VT"  "FF"  "CR"  "SO"  "SI"
+		     "DLE" "DC1" "DC2" "DC3" "DC4" "NAK" "SYN" "ETB"
+		     "CAN" "EM"  "SUB" "ESC" "FC"  "GS"  "RS"  "US")))
+  (dotimes (i 32)
+    (aset char-acronym-table i (car c0-acronyms))
+    (setq c0-acronyms (cdr c0-acronyms))))
+
+(let ((c1-acronyms '("XXX" "XXX" "BPH" "NBH" "IND" "NEL" "SSA" "ESA"
+		     "HTS" "HTJ" "VTS" "PLD" "PLU" "R1"  "SS2" "SS1"
+		     "DCS" "PU1" "PU2" "STS" "CCH" "MW"  "SPA" "EPA"
+		     "SOS" "XXX" "SC1" "CSI" "ST"  "OSC" "PM"  "APC")))
+  (dotimes (i 32)
+    (aset char-acronym-table (+ #x0080 i) (car c1-acronyms))
+    (setq c1-acronyms (cdr c1-acronyms))))
+
+(aset char-acronym-table #x17B4 "KIVAQ")   ; KHMER VOWEL INHERENT AQ
+(aset char-acronym-table #x17B5 "KIVAA")   ; KHMER VOWEL INHERENT AA
+(aset char-acronym-table #x200B "ZWSP")    ; ZERO WIDTH SPACE
+(aset char-acronym-table #x200C "ZWNJ")    ; ZERO WIDTH NON-JOINER
+(aset char-acronym-table #x200D "ZWJ")	   ; ZERO WIDTH JOINER
+(aset char-acronym-table #x200E "LRM")	   ; LEFT-TO-RIGHT MARK
+(aset char-acronym-table #x200F "RLM")	   ; RIGHT-TO-LEFT MARK
+(aset char-acronym-table #x202A "LRE")	   ; LEFT-TO-RIGHT EMBEDDING
+(aset char-acronym-table #x202B "RLE")	   ; RIGHT-TO-LEFT EMBEDDING
+(aset char-acronym-table #x202C "PDF")	   ; POP DIRECTIONAL FORMATTING
+(aset char-acronym-table #x202D "LRO")	   ; LEFT-TO-RIGHT OVERRIDE
+(aset char-acronym-table #x202E "RLO")	   ; RIGHT-TO-LEFT OVERRIDE
+(aset char-acronym-table #x2060 "WJ")	   ; WORD JOINER
+(aset char-acronym-table #x206A "ISS")	   ; INHIBIT SYMMETRIC SWAPPING
+(aset char-acronym-table #x206B "ASS")	   ; ACTIVATE SYMMETRIC SWAPPING
+(aset char-acronym-table #x206C "IAFS")    ; INHIBIT ARABIC FORM SHAPING
+(aset char-acronym-table #x206D "AAFS")    ; ACTIVATE ARABIC FORM SHAPING
+(aset char-acronym-table #x206E "NADS")    ; NATIONAL DIGIT SHAPES
+(aset char-acronym-table #x206F "NODS")    ; NOMINAL DIGIT SHAPES
+(aset char-acronym-table #xFEFF "ZWNBSP")  ; ZERO WIDTH NO-BREAK SPACE
+(aset char-acronym-table #xFFF9 "IAA")	   ; INTERLINEAR ANNOTATION ANCHOR
+(aset char-acronym-table #xFFFA "IAS")     ; INTERLINEAR ANNOTATION SEPARATOR
+(aset char-acronym-table #xFFFB "IAT")     ; INTERLINEAR ANNOTATION TERMINATOR
+(aset char-acronym-table #x1D173 "BEGBM")  ; MUSICAL SYMBOL BEGIN BEAM
+(aset char-acronym-table #x1D174 "ENDBM")  ; MUSICAL SYMBOL END BEAM
+(aset char-acronym-table #x1D175 "BEGTIE") ; MUSICAL SYMBOL BEGIN TIE
+(aset char-acronym-table #x1D176 "END")	   ; MUSICAL SYMBOL END TIE
+(aset char-acronym-table #x1D177 "BEGSLR") ; MUSICAL SYMBOL BEGIN SLUR
+(aset char-acronym-table #x1D178 "ENDSLR") ; MUSICAL SYMBOL END SLUR
+(aset char-acronym-table #x1D179 "BEGPHR") ; MUSICAL SYMBOL BEGIN PHRASE
+(aset char-acronym-table #x1D17A "ENDPHR") ; MUSICAL SYMBOL END PHRASE
+(aset char-acronym-table #xE0001 "|->TAG") ; LANGUAGE TAG
+(aset char-acronym-table #xE0020 "SP TAG") ; TAG SPACE
+(dotimes (i 94)
+  (aset char-acronym-table (+ #xE0021 i) (format " %c TAG" (+ 33 i))))
+(aset char-acronym-table #xE007F "->|TAG") ; CANCEL TAG
+
+;;; Control of displaying glyphless characters.
+(defvar glyphless-char-control
+  '((format-control . thin-space)
+    (no-font . hexa-code))
+  "List of directives to control displaying of glyphless characters.
+
+Each element has the form (TARGET . METHOD), where TARGET is a
+symbol specifying the target character group to control, and
+METHOD is a symbol specifying the method of displaying them.
+
+TARGET must be one of these symbols:
+  `c0-control': U+0000..U+001F.
+  `c1-control': U+0080..U+009F.
+  `format-control': Characters of Unicode General Category `Cf'.
+     Ex: U+200C (ZWNJ), U+200E (LRM)), but don't include characters
+     that have graphic image such as U+00AD (SHY).
+  `no-font': characters for which no suitable font is found.
+
+METHOD must be one of these symbols:
+  `zero-width': don't display.
+  `thin-space': display a thin space (1-pixel width).
+  `empty-box': display an empty box.
+  `acronym': display an acronum string in a box.
+  `hexa-code': display a hexadecimal character code in a box.
+
+Just setting this variable does not take effect.  Call the
+function `update-glyphless-char-display' (which see) after
+setting this variable.")
+
+(defun update-glyphless-char-display ()
+  "Make the setting of `glyphless-char-control' take effect.
+This function updates the char-table `glyphless-char-display'."
+  (dolist (elt glyphless-char-control)
+    (let ((target (car elt))
+	  (method (cdr elt)))
+      (cond ((eq target 'c0-control)
+	     (set-char-table-range glyphless-char-display '(#x00 . #x1F)
+				   method))
+	    ((eq target 'c1-control)
+	     (set-char-table-range glyphless-char-display '(#x80 . #x9F)
+				   method))
+	    ((eq target 'format-control)
+	     (map-char-table
+	      #'(lambda (char category)
+		  (if (eq category 'Cf)
+		      (let ((this-method method)
+			    from to)
+			(if (consp char)
+			    (setq from (car char) to (cdr char))
+			  (setq from char to char))
+			(while (<= from to)
+			  (when (/= from #xAD)
+			    (if (eq method 'acronym)
+				(setq this-method 
+				      (aref char-acronym-table from)))
+			    (set-char-table-range glyphless-char-display
+						  from this-method))
+			  (setq from (1+ from))))))
+	      unicode-category-table))
+	    ((eq target 'no-font)
+	     (set-char-table-extra-slot glyphless-char-display 0 method))
+	    (t
+	     (error "Invalid target character group: %s" target))))))
+
+(update-glyphless-char-display)
+
 ;;; Setting word boundary.
 
 (setq word-combining-categories
--- a/lisp/international/fontset.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/international/fontset.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/international/mule.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/international/titdic-cnv.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/iswitchb.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/loadup.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/ls-lisp.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/mail/emacsbug.el	Mon Nov 08 14:19:54 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/mail-extr.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/mail/mail-extr.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,8 @@
 ;;; mail-extr.el --- extract full name and address from RFC 822 mail header -*- coding: utf-8 -*-
 
 ;; Copyright (C) 1991, 1992, 1993, 1994, 1997, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;;   2005, 2006, 2007, 2008, 2009, 2010
+;;   Free Software Foundation, Inc.
 
 ;; Author: Joe Wells <jbw@cs.bu.edu>
 ;; Maintainer: FSF
@@ -691,8 +692,8 @@
 ;;
 
 (defvar disable-initial-guessing-flag)	; dynamic assignment
-(defvar cbeg)				; dynamic assignment
-(defvar cend)				; dynamic assignment
+(defvar mailextr-cbeg)			; dynamic assignment
+(defvar mailextr-cend)			; dynamic assignment
 (defvar mail-extr-all-top-level-domains) ; Defined below.
 
 ;;;###autoload
@@ -762,7 +763,8 @@
 	      record-pos-symbol
 	      first-real-pos last-real-pos
 	      phrase-beg phrase-end
-	      cbeg cend			; dynamically set from -voodoo
+	      ;; Dynamically set in mail-extr-voodoo.
+	      mailextr-cbeg mailextr-cend
 	      quote-beg quote-end
 	      atom-beg atom-end
 	      mbox-beg mbox-end
@@ -796,19 +798,19 @@
 	     ((eq char ?\()
 	      (set-syntax-table mail-extr-address-comment-syntax-table)
 	      ;; only record the first non-empty comment's position
-	      (if (and (not cbeg)
+	      (if (and (not mailextr-cbeg)
 		       (save-excursion
 			 (forward-char 1)
 			 (mail-extr-skip-whitespace-forward)
 			 (not (eq ?\) (char-after (point))))))
-		  (setq cbeg (point)))
+		  (setq mailextr-cbeg (point)))
 	      ;; TODO: don't record if unbalanced
 	      (or (mail-extr-safe-move-sexp 1)
 		  (forward-char 1))
 	      (set-syntax-table mail-extr-address-syntax-table)
-	      (if (and cbeg
-		       (not cend))
-		  (setq cend (point))))
+	      (if (and mailextr-cbeg
+		       (not mailextr-cend))
+		  (setq mailextr-cend (point))))
 	     ;; quoted text
 	     ((eq char ?\")
 	      ;; only record the first non-empty quote's position
@@ -994,10 +996,10 @@
 		 (> last-real-pos (1+ group-\;-pos))
 		 (setq last-real-pos (1+ group-\;-pos)))
 	    ;; *** This may be wrong:
-	    (and cend
-		 (> cend group-\;-pos)
-		 (setq cend nil
-		       cbeg nil))
+	    (and mailextr-cend
+		 (> mailextr-cend group-\;-pos)
+		 (setq mailextr-cend nil
+		       mailextr-cbeg nil))
 	    (and quote-end
 		 (> quote-end group-\;-pos)
 		 (setq quote-end nil
@@ -1228,8 +1230,8 @@
 		 (narrow-to-region phrase-beg phrase-end))
 
 		;; Example: fml@foo.bar.dom (First M. Last)
-		(cbeg
-		 (narrow-to-region (1+ cbeg) (1- cend))
+		(mailextr-cbeg
+		 (narrow-to-region (1+ mailextr-cbeg) (1- mailextr-cend))
 		 (mail-extr-undo-backslash-quoting (point-min) (point-max))
 
 		 ;; Deal with spacing problems
@@ -1472,7 +1474,6 @@
 	  (case-fold-search nil)
 	  mixed-case-flag lower-case-flag ;;upper-case-flag
 	  suffix-flag last-name-comma-flag
-	  ;;cbeg cend
 	  initial
 	  begin-again-flag
 	  drop-this-word-if-trailing-flag
@@ -1618,7 +1619,7 @@
 
 	   ;; Delete parenthesized/quoted comment/nickname
 	   ((memq (following-char) '(?\( ?\{ ?\[ ?\" ?\' ?\`))
-	    (setq cbeg (point))
+	    (setq mailextr-cbeg (point))
 	    (set-syntax-table mail-extr-address-text-comment-syntax-table)
 	    (cond ((memq (following-char) '(?\' ?\`))
 		   (or (search-forward "'" nil t
@@ -1628,23 +1629,23 @@
 		   (or (mail-extr-safe-move-sexp 1)
 		       (goto-char (point-max)))))
 	    (set-syntax-table mail-extr-address-text-syntax-table)
-	    (setq cend (point))
+	    (setq mailextr-cend (point))
 	    (cond
 	     ;; Handle case of entire name being quoted
 	     ((and (eq word-count 0)
 		   (looking-at " *\\'")
-		   (>= (- cend cbeg) 2))
-	      (narrow-to-region (1+ cbeg) (1- cend))
+		   (>= (- mailextr-cend mailextr-cbeg) 2))
+	      (narrow-to-region (1+ mailextr-cbeg) (1- mailextr-cend))
 	      (goto-char (point-min)))
 	     (t
 	      ;; Handle case of quoted initial
-	      (if (and (or (= 3 (- cend cbeg))
-			   (and (= 4 (- cend cbeg))
-				(eq ?. (char-after (+ 2 cbeg)))))
+	      (if (and (or (= 3 (- mailextr-cend mailextr-cbeg))
+			   (and (= 4 (- mailextr-cend mailextr-cbeg))
+				(eq ?. (char-after (+ 2 mailextr-cbeg)))))
 		       (not (looking-at " *\\'")))
-		  (setq initial (char-after (1+ cbeg)))
+		  (setq initial (char-after (1+ mailextr-cbeg)))
 		(setq initial nil))
-	      (delete-region cbeg cend)
+	      (delete-region mailextr-cbeg mailextr-cend)
 	      (if initial
 		  (insert initial ". ")))))
 
@@ -2174,5 +2175,4 @@
 
 (provide 'mail-extr)
 
-;; arch-tag: 7785fade-1073-4ed6-b4f6-28db34a7982d
 ;;; mail-extr.el ends here
--- a/lisp/mail/mspools.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/mail/mspools.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/mail/rmail.el	Mon Nov 08 14:19:54 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/mail/sendmail.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/mail/sendmail.el	Mon Nov 08 14:19:54 2010 +0900
@@ -718,7 +718,7 @@
   "Carry out Auto Fill for Mail mode.
 If within the headers, this makes the new lines into continuation lines."
   (if (< (point) (mail-header-end))
-      (let ((old-line-start (save-excursion (beginning-of-line) (point))))
+      (let ((old-line-start (line-beginning-position)))
 	(if (do-auto-fill)
 	    (save-excursion
 	      (beginning-of-line)
@@ -1955,5 +1955,4 @@
 
 (provide 'sendmail)
 
-;; arch-tag: 48bc1025-d993-4d31-8d81-2a29491f0626
 ;;; sendmail.el ends here
--- a/lisp/makesum.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/makesum.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,7 @@
 ;;; makesum.el --- generate key binding summary for Emacs
 
-;; Copyright (C) 1985, 2001, 2002, 2003, 2004, 2005,
-;;   2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+;;   2009, 2010  Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: help
@@ -98,7 +98,7 @@
        (forward-line half)
        (while (< half nlines)
 	 (setq half (1+ half))
-	 (setq line (buffer-substring (point) (save-excursion (end-of-line) (point))))
+	 (setq line (buffer-substring (point) (line-end-position)))
 	 (setq lines (cons line lines))
 	 (delete-region (point) (progn (forward-line 1) (point)))))
       (setq lines (nreverse lines))
@@ -112,5 +112,4 @@
 
 (provide 'makesum)
 
-;; arch-tag: c2383336-fc89-46ad-8110-ded42bffaee3
 ;;; makesum.el ends here
--- a/lisp/menu-bar.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/menu-bar.el	Mon Nov 08 14:19:54 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,12 +71,20 @@
 (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))
 
-;; This alias is for compatibility with 19.28 and before.
-(defvar menu-bar-files-menu 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)))
+
+;; Only declared obsolete (and only made a proper alias) in 23.3.
+(define-obsolete-variable-alias 'menu-bar-files-menu 'menu-bar-file-menu "22.1")
 
 ;; This is referenced by some code below; it is defined in uniquify.el
 (defvar uniquify-buffer-name-style)
@@ -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."
@@ -2020,7 +2073,8 @@
 turn on menu bars; otherwise, turn off menu bars."
   :init-value t
   :global t
-  :group 'frames
+  ;; It's defined in C/cus-start, this stops the d-m-m macro defining it again.
+  :variable menu-bar-mode
 
   ;; Turn the menu-bars on all frames on or off.
   (let ((val (if menu-bar-mode 1 0)))
@@ -2082,5 +2136,4 @@
 
 (provide 'menu-bar)
 
-;; arch-tag: 6e6a3c22-4ec4-4d3d-8190-583f8ef94ced
 ;;; menu-bar.el ends here
--- a/lisp/mh-e/ChangeLog	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/mh-e/ChangeLog	Mon Nov 08 14:19:54 2010 +0900
@@ -1,3 +1,11 @@
+2010-11-07  Glenn Morris  <rgm@gnu.org>
+
+	* mh-seq.el (mh-read-msg-list): Use point-at-eol.
+
+2010-11-03  Glenn Morris  <rgm@gnu.org>
+
+	* mh-mime.el (dots, type, ov): Avoid unnecessary declaration.
+
 2010-05-14  Peter S Galbraith  <psg@debian.org>
 
 	* mh-mime.el (mh-decode-message-subject): New function to decode
--- a/lisp/mh-e/ChangeLog.1	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/mh-e/ChangeLog.1	Mon Nov 08 14:19:54 2010 +0900
@@ -5452,7 +5452,7 @@
 	from mh-exec-cmd.
 
 	* mh-utils.el (mh-temp-folders-buffer): Sequences and folders
-	loose the -temp from their buffer names as they are interesting to
+	lose the -temp from their buffer names as they are interesting to
 	the user.
 
 	* mh-seq.el (mh-list-sequences): New name, mh-sequences-buffer as
@@ -11400,7 +11400,8 @@
 	(dist): Leave release in current directory.
 
 
-  Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
+  Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+    Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
@@ -11417,4 +11418,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: 2577172b-b1bf-4d87-acfb-c9d8780e8851
--- a/lisp/mh-e/mh-mime.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/mh-e/mh-mime.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,8 +1,7 @@
 ;;; mh-mime.el --- MH-E MIME support
 
-;; Copyright (C) 1993, 1995,
-;;   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-;;   Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1995, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+;;   2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: Bill Wohler <wohler@newt.com>
 ;; Maintainer: Bill Wohler <wohler@newt.com>
@@ -837,9 +836,10 @@
 ;;; Button Display
 
 ;; Shush compiler.
-(defvar dots)                           ; XEmacs
-(defvar type)                           ; XEmacs
-(defvar ov)                             ; XEmacs
+(when (featurep 'xemacs)
+  (defvar dots)
+  (defvar type)
+  (defvar ov))
 
 (defun mh-insert-mime-button (handle index displayed)
   "Insert MIME button for HANDLE.
@@ -1834,5 +1834,4 @@
 ;; sentence-end-double-space: nil
 ;; End:
 
-;; arch-tag: 0dd36518-1b64-4a84-8f4e-59f422d3f002
 ;;; mh-mime.el ends here
--- a/lisp/mh-e/mh-seq.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/mh-e/mh-seq.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,8 +1,7 @@
 ;;; mh-seq.el --- MH-E sequences support
 
-;; Copyright (C) 1993, 1995,
-;;   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-;;   Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1995, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+;;   2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: Bill Wohler <wohler@newt.com>
 ;; Maintainer: Bill Wohler <wohler@newt.com>
@@ -819,7 +818,7 @@
   "Return a list of message numbers from point to the end of the line.
 Expands ranges into set of individual numbers."
   (let ((msgs ())
-        (end-of-line (save-excursion (end-of-line) (point)))
+        (end-of-line (point-at-eol))
         num)
     (while (re-search-forward "[0-9]+" end-of-line t)
       (setq num (string-to-number (buffer-substring (match-beginning 0)
@@ -1017,5 +1016,4 @@
 ;; sentence-end-double-space: nil
 ;; End:
 
-;; arch-tag: 8e952711-01a2-485b-bf21-c9e3ad4de942
 ;;; mh-seq.el ends here
--- a/lisp/minibuffer.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/minibuffer.el	Mon Nov 08 14:19:54 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/misc.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/misc.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,7 @@
 ;;; misc.el --- some nonstandard basic editing commands for Emacs
 
-;; Copyright (C) 1989, 2001, 2002, 2003, 2004, 2005,
-;;   2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1989, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+;;   2009, 2010  Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: convenience
@@ -54,7 +54,7 @@
       (setq string (concat string
 			   (buffer-substring
 			    (point)
-			    (min (save-excursion (end-of-line) (point))
+			    (min (line-end-position)
 				 (+ n (point)))))))
     (insert string)))
 
@@ -132,5 +132,4 @@
 
 (provide 'misc)
 
-;; arch-tag: 908f7884-c19e-4388-920c-9cfa425e449b
 ;;; misc.el ends here
--- a/lisp/mouse-sel.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/mouse-sel.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,7 @@
 ;;; mouse-sel.el --- multi-click selection support for Emacs 19
 
-;; Copyright (C) 1993, 1994, 1995, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1994, 1995, 2001, 2002, 2003, 2004, 2005, 2006,
+;;   2007, 2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: Mike Williams <mdub@bigfoot.com>
 ;; Keywords: mouse
@@ -299,7 +299,7 @@
 	SELECTION-THING-SYMBOL 	= name of variable where the current selection
  				  type for this selection should be stored.")
 
-(declare-function x-select-text "term/x-win" (text))
+(declare-function x-select-text "term/common-win" (text))
 
 (defvar mouse-sel-set-selection-function
   (if (eq mouse-sel-default-bindings 'interprogram-cut-paste)
@@ -314,7 +314,7 @@
   SELECTION, the name of the selection concerned, and
   VALUE, the text to store.
 
-This sets the selection, unless `mouse-sel-default-bindings' 
+This sets the selection, unless `mouse-sel-default-bindings'
 is `interprogram-cut-paste'.")
 
 (declare-function x-selection-value "term/x-win" ())
@@ -749,5 +749,4 @@
 
 (provide 'mouse-sel)
 
-;; arch-tag: 86e6c73f-deaa-48d3-a24e-c565fda1f7d7
 ;;; mouse-sel.el ends here
--- a/lisp/mouse.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/mouse.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1280,7 +1280,7 @@
   (or mouse-yank-at-point (mouse-set-point click))
   (let ((primary
 	 (cond
-	  ((fboundp 'x-get-selection-value) ; MS-DOS and MS-Windows
+	  ((fboundp 'x-get-selection-value) ; MS-DOS, MS-Windows and X.
 	   (or (x-get-selection-value)
 	       (x-get-selection 'PRIMARY)))
 	  ;; FIXME: What about xterm-mouse-mode etc.?
--- a/lisp/net/ange-ftp.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/net/ange-ftp.el	Mon Nov 08 14:19:54 2010 +0900
@@ -4901,7 +4901,7 @@
 ;;  ;; This is the Unix dl version.
 ;;  (let ((opoint (point))
 ;;	case-fold-search hidden)
-;;    (or eol (setq eol (save-excursion (end-of-line) (point))))
+;;    (or eol (setq eol (line-end-position)))
 ;;    (setq hidden (and selective-display
 ;;		       (save-excursion
 ;;			 (search-forward "\r" eol t))))
@@ -5300,7 +5300,7 @@
 ;;  ;; This is the VMS version.
 ;;  (let (opoint hidden case-fold-search)
 ;;    (setq opoint (point))
-;;    (or eol (setq eol (save-excursion (end-of-line) (point))))
+;;    (or eol (setq eol (line-end-position)))
 ;;    (setq hidden (and selective-display
 ;;		      (save-excursion (search-forward "\r" eol t))))
 ;;    (if hidden
@@ -5658,7 +5658,7 @@
 ;;  ;; This is the MTS version.
 ;;  (let (opoint hidden case-fold-search)
 ;;    (setq opoint (point)
-;;	  eol (save-excursion (end-of-line) (point))
+;;	  eol (line-end-position)
 ;;	  hidden (and selective-display
 ;;		      (save-excursion (search-forward "\r" eol t))))
 ;;    (if hidden
@@ -5879,7 +5879,7 @@
 ;;  ;; This is the CMS version.
 ;;  (let ((opoint (point))
 ;;	case-fold-search hidden)
-;;    (or eol (setq eol (save-excursion (end-of-line) (point))))
+;;    (or eol (setq eol (line-end-position)))
 ;;    (setq hidden (and selective-display
 ;;		      (save-excursion
 ;;			(search-forward "\r" eol t))))
@@ -6153,5 +6153,4 @@
 
 (provide 'ange-ftp)
 
-;; arch-tag: 2987ef88-cb56-4ec1-87a9-79132572e316
 ;;; ange-ftp.el ends here
--- a/lisp/net/dbus.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/net/dbus.el	Mon Nov 08 14:19:54 2010 +0900
@@ -239,7 +239,7 @@
 arrived.  SERVICE is the object name for which the name owner has
 been changed.  OLD-OWNER is the previous owner of SERVICE, or the
 empty string if SERVICE was not owned yet.  NEW-OWNER is the new
-owner of SERVICE, or the empty string if SERVICE looses any name owner.
+owner of SERVICE, or the empty string if SERVICE loses any name owner.
 
 usage: (dbus-name-owner-changed-handler service old-owner new-owner)"
   (save-match-data
@@ -1010,5 +1010,4 @@
 
 (provide 'dbus)
 
-;; arch-tag: a47caf84-9162-4811-90cc-5d388e37b9bd
 ;;; dbus.el ends here
--- a/lisp/net/gnutls.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/net/gnutls.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,4 +1,5 @@
 ;;; gnutls.el --- Support SSL/TLS connections through GnuTLS
+
 ;; Copyright (C) 2010 Free Software Foundation, Inc.
 
 ;; Author: Ted Zlatanov <tzz@lifelogs.com>
@@ -65,6 +66,8 @@
   (let ((proc (open-network-stream name buffer host service)))
     (gnutls-negotiate proc 'gnutls-x509pki)))
 
+(declare-function gnutls-boot "gnutls.c" (proc type proplist))
+
 (defun gnutls-negotiate (proc type &optional priority-string
                               trustfiles keyfiles)
   "Negotiate a SSL/TLS connection.
@@ -95,6 +98,9 @@
 
     proc))
 
+(declare-function gnutls-errorp "gnutls.c" (error))
+(declare-function gnutls-error-string "gnutls.c" (error))
+
 (defun gnutls-message-maybe (doit format &rest params)
   "When DOIT, message with the caller name followed by FORMAT on PARAMS."
   ;; (apply 'debug format (or params '(nil)))
--- a/lisp/net/mairix.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/net/mairix.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/net/tls.el	Mon Nov 08 14:19:54 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-compat.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/net/tramp-compat.el	Mon Nov 08 14:19:54 2010 +0900
@@ -199,6 +199,8 @@
   (ignore-errors
     (tramp-compat-funcall 'font-lock-add-keywords mode keywords how)))
 
+;; FIXME is this really necessary?  Eg Emacs has both l-b-p and p-at-b
+;; since at least 21.1.
 (defsubst tramp-compat-line-beginning-position ()
   "Return point at beginning of line (compat function).
 Calls `line-beginning-position' or `point-at-bol' if defined, else
@@ -209,6 +211,8 @@
    ((fboundp 'point-at-bol) (tramp-compat-funcall 'point-at-bol))
    (t (save-excursion (beginning-of-line) (point)))))
 
+;; FIXME is this really necessary?  Eg Emacs has both l-e-p and p-at-e
+;; since at least 21.1.
 (defsubst tramp-compat-line-end-position ()
   "Return point at end of line (compat function).
 Calls `line-end-position' or `point-at-eol' if defined, else
@@ -529,5 +533,4 @@
 
 ;;; TODO:
 
-;; arch-tag: 0e724b18-6699-4f87-ad96-640b272e5c85
 ;;; tramp-compat.el ends here
--- a/lisp/net/tramp-sh.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/net/tramp-sh.el	Mon Nov 08 14:19:54 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/net/tramp.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/net/tramp.el	Mon Nov 08 14:19:54 2010 +0900
@@ -2861,7 +2861,11 @@
 	    (setq buffer-file-name filename)
 	    (setq buffer-read-only (not (file-writable-p filename)))
 	    (set-visited-file-modtime)
-	    (set-buffer-modified-p nil))
+	    (set-buffer-modified-p nil)
+	    ;; For root, preserve owner and group when editing files.
+	    (when (string-equal (file-remote-p filename 'user) "root")
+	      (set (make-local-variable 'backup-by-copying-when-mismatch) t)
+	      (put 'backup-by-copying-when-mismatch 'permanent-local t)))
 	  (when (and (stringp local-copy)
 		     (or remote-copy (null tramp-temp-buffer-file-name)))
 	    (delete-file local-copy))
--- a/lisp/newcomment.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/newcomment.el	Mon Nov 08 14:19:54 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-maint.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/nxml/nxml-maint.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,6 +1,7 @@
 ;;; nxml-maint.el --- commands for maintainers of nxml-*.el
 
-;; Copyright (C) 2003, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007, 2008, 2009, 2010
+;;   Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: XML
@@ -78,7 +79,7 @@
       (goto-char (point-min))
       (while (re-search-forward "^ *\\([a-FA-F0-9]\\{2\\}\\)[ \t]+" nil t)
 	(let ((row (match-string 1))
-	      (eol (save-excursion (end-of-line) (point))))
+	      (eol (line-end-position)))
 	  (while (re-search-forward "\\([a-FA-F0-9]\\{2\\}\\)-\\([a-FA-F0-9]\\{2\\}\\)\\|\\([a-FA-F0-9]\\{2\\}\\)" eol t)
 	    (setq lst
 		  (cons (if (match-beginning 3)
@@ -102,5 +103,4 @@
 
 (provide 'nxml-maint)
 
-;; arch-tag: 2cff6b55-12af-47db-90da-a91f782f435a
 ;;; nxml-maint.el ends here
--- a/lisp/nxml/nxml-mode.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/nxml/nxml-mode.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/obsolete/lazy-lock.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/org/ChangeLog	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/paren.el	Mon Nov 08 14:19:54 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/decipher.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/play/decipher.el	Mon Nov 08 14:19:54 2010 +0900
@@ -487,7 +487,7 @@
       (let ((font-lock-fontify-region-function 'ignore))
         ;; insert-and-inherit will pick the right face automatically
         (while (search-forward-regexp "^:" nil t)
-          (setq bound (save-excursion (end-of-line) (point)))
+          (setq bound (point-at-eol))
           (while (search-forward cipher-string bound 'end)
             (decipher-insert plain-char)))))))
 
@@ -1062,5 +1062,4 @@
 ;;          (delete-char -1)
 ;;          (insert ")\n"))))))
 
-;; arch-tag: 8f094d88-ffe1-4f99-afe3-a5e81dd939d9
 ;;; decipher.el ends here
--- a/lisp/play/doctor.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/play/doctor.el	Mon Nov 08 14:19:54 2010 +0900
@@ -29,40 +29,94 @@
 
 ;;; Code:
 
-(defvar **mad**)        (defvar *debug*)      (defvar *print-space*)
-(defvar *print-upcase*) (defvar abuselst)     (defvar abusewords)
-(defvar account)        (defvar afraidof)     (defvar arerelated)
-(defvar areyou)         (defvar bak)          (defvar beclst)
-(defvar bother)         (defvar bye)          (defvar canyou)
-(defvar chatlst)        (defvar continue)     (defvar deathlst)
-(defvar describe)       (defvar drnk)         (defvar drugs)
-(defvar eliza-flag)     (defvar elizalst)     (defvar famlst)
-(defvar feared)         (defvar fears)        (defvar feelings-about)
-(defvar foullst)        (defvar found)        (defvar hello)
-(defvar history)        (defvar howareyoulst) (defvar howdyflag)
-(defvar huhlst)         (defvar ibelieve)     (defvar improve)
-(defvar inter)          (defvar isee)         (defvar isrelated)
-(defvar lincount)       (defvar longhuhlst)   (defvar lover)
-(defvar machlst)        (defvar mathlst)      (defvar maybe)
-(defvar moods)          (defvar neglst)       (defvar obj)
-(defvar object)         (defvar owner)        (defvar please)
-(defvar problems)       (defvar qlist)        (defvar random-adjective)
-(defvar relation)       (defvar remlst)       (defvar repetitive-shortness)
-(defvar replist)        (defvar rms-flag)     (defvar schoollst)
-(defvar sent)           (defvar sexlst)       (defvar shortbeclst)
-(defvar shortlst)       (defvar something)    (defvar sportslst)
-(defvar stallmanlst)    (defvar states)       (defvar subj)
-(defvar suicide-flag)   (defvar sure)         (defvar thing)
-(defvar things)         (defvar thlst)        (defvar toklst)
-(defvar typos)          (defvar verb)         (defvar want)
-(defvar whatwhen)       (defvar whereoutp)    (defvar whysay)
-(defvar whywant)        (defvar zippy-flag)   (defvar zippylst)
+(defvar doctor--**mad**)
+(defvar doctor--*print-space*)
+(defvar doctor--*print-upcase*)
+(defvar doctor--abuselst)
+(defvar doctor--abusewords)
+(defvar doctor--afraidof)
+(defvar doctor--arerelated)
+(defvar doctor--areyou)
+(defvar doctor--bak)
+(defvar doctor--beclst)
+(defvar doctor--bother)
+(defvar doctor--bye)
+(defvar doctor--canyou)			; unused?
+(defvar doctor--chatlst)
+(defvar doctor--continue)
+(defvar doctor--deathlst)
+(defvar doctor--describe)
+(defvar doctor--drnk)
+(defvar doctor--drugs)
+(defvar doctor--eliza-flag)
+(defvar doctor--elizalst)
+(defvar doctor--famlst)
+(defvar doctor--feared)
+(defvar doctor--fears)
+(defvar doctor--feelings-about)
+(defvar doctor--foullst)
+(defvar doctor-found)
+(defvar doctor--hello)
+(defvar doctor--history)
+(defvar doctor--howareyoulst)
+(defvar doctor--howdyflag)
+(defvar doctor--huhlst)
+(defvar doctor--ibelieve)
+(defvar doctor--improve)
+(defvar doctor--inter)
+(defvar doctor--isee)
+(defvar doctor--isrelated)
+(defvar doctor--lincount)
+(defvar doctor--longhuhlst)
+(defvar doctor--lover)
+(defvar doctor--machlst)
+(defvar doctor--mathlst)
+(defvar doctor--maybe)
+(defvar doctor--moods)
+(defvar doctor--neglst)
+(defvar doctor-obj)
+(defvar doctor-object)
+(defvar doctor-owner)
+(defvar doctor--please)
+(defvar doctor--problems)
+(defvar doctor--qlist)
+(defvar doctor--random-adjective)
+(defvar doctor--relation)
+(defvar doctor--remlst)
+(defvar doctor--repetitive-shortness)
+(defvar doctor--replist)
+(defvar doctor--rms-flag)
+(defvar doctor--schoollst)
+(defvar doctor-sent)
+(defvar doctor--sexlst)
+(defvar doctor--shortbeclst)
+(defvar doctor--shortlst)
+(defvar doctor--something)
+(defvar doctor--sportslst)
+(defvar doctor--stallmanlst)
+(defvar doctor--states)
+(defvar doctor-subj)
+(defvar doctor--suicide-flag)
+(defvar doctor--sure)
+(defvar doctor--thing)
+(defvar doctor--things)
+(defvar doctor--thlst)
+(defvar doctor--toklst)
+(defvar doctor--typos)
+(defvar doctor-verb)
+(defvar doctor--want)
+(defvar doctor--whatwhen)
+(defvar doctor--whereoutp)
+(defvar doctor--whysay)
+(defvar doctor--whywant)
+(defvar doctor--zippy-flag)
+(defvar doctor--zippylst)
 
 (defun doc// (x) x)
 
 (defmacro doc$ (what)
   "quoted arg form of doctor-$"
-  (list 'doctor-$ (list 'quote what)))
+  `(doctor-$ ',what))
 
 (defun doctor-$ (what)
   "Return the car of a list, rotating the list each time"
@@ -86,484 +140,411 @@
   (make-doctor-variables)
   (turn-on-auto-fill)
   (doctor-type '(i am the psychotherapist \.
-		 (doc$ please) (doc$ describe) your (doc$ problems) \.
+		 (doc$ doctor--please) (doc$ doctor--describe) your (doc$ doctor--problems) \.
 		 each time you are finished talking, type \R\E\T twice \.))
   (insert "\n"))
 
 (defun make-doctor-variables ()
-  (make-local-variable 'typos)
-  (setq typos
-	(mapcar (function (lambda (x)
-			    (put (car x) 'doctor-correction  (cadr x))
-			    (put (cadr x) 'doctor-expansion (car (cddr x)))
-			    (car x)))
-		'((theyll they\'ll (they will))
-		  (theyre they\'re (they are))
-		  (hes he\'s (he is))
-		  (he7s he\'s (he is))
-		  (im i\'m (you are))
-		  (i7m i\'m (you are))
-		  (isa is\ a (is a))
-		  (thier their (their))
-		  (dont don\'t (do not))
-		  (don7t don\'t (do not))
-		  (you7re you\'re (i am))
-		  (you7ve you\'ve (i have))
-		  (you7ll you\'ll (i will)))))
-  (make-local-variable 'found)
-  (setq found nil)
-  (make-local-variable 'owner)
-  (setq owner nil)
-  (make-local-variable 'history)
-  (setq history nil)
-  (make-local-variable '*debug*)
-  (setq *debug* nil)
-  (make-local-variable 'inter)
-  (setq inter
-	'((well\,)
-	  (hmmm \.\.\.\ so\,)
-	  (so)
-	  (\.\.\.and)
-	  (then)))
-  (make-local-variable 'continue)
-  (setq continue
-	'((continue)
-	  (proceed)
-	  (go on)
-	  (keep going) ))
-  (make-local-variable 'relation)
-  (setq relation
-	'((your relationship with)
-	  (something you remember about)
-	  (your feelings toward)
-	  (some experiences you have had with)
-	  (how you feel about)))
-  (make-local-variable 'fears)
-  (setq fears '( ((doc$ whysay) you are (doc$ afraidof) (doc// feared) \?)
-		 (you seem terrified by (doc// feared) \.)
-		 (when did you first feel (doc$ afraidof) (doc// feared) \?) ))
-  (make-local-variable 'sure)
-  (setq sure '((sure)(positive)(certain)(absolutely sure)))
-  (make-local-variable 'afraidof)
-  (setq afraidof '( (afraid of) (frightened by) (scared of) ))
-  (make-local-variable 'areyou)
-  (setq areyou '( (are you)(have you been)(have you been) ))
-  (make-local-variable 'isrelated)
-  (setq isrelated '( (has something to do with)(is related to)
-		     (could be the reason for) (is caused by)(is because of)))
-  (make-local-variable 'arerelated)
-  (setq arerelated '((have something to do with)(are related to)
-		     (could have caused)(could be the reason for) (are caused by)
-		     (are because of)))
-  (make-local-variable 'moods)
-  (setq moods '( ((doc$ areyou)(doc// found) often \?)
-		 (what causes you to be (doc// found) \?)
-		 ((doc$ whysay) you are (doc// found) \?) ))
-  (make-local-variable 'maybe)
-  (setq maybe
-	'((maybe)
-	  (perhaps)
-	  (possibly)))
-  (make-local-variable 'whatwhen)
-  (setq whatwhen
-	'((what happened when)
-	  (what would happen if)))
-  (make-local-variable 'hello)
-  (setq hello
-	'((how do you do \?) (hello \.) (howdy!) (hello \.) (hi \.) (hi there \.)))
-  (make-local-variable 'drnk)
-  (setq drnk
-	'((do you drink a lot of (doc// found) \?)
-	  (do you get drunk often \?)
-	  ((doc$ describe) your drinking habits \.) ))
-  (make-local-variable 'drugs)
-  (setq drugs '( (do you use (doc// found) often \?)((doc$ areyou)
-						 addicted to (doc// found) \?)(do you realize that drugs can
-						 be very harmful \?)((doc$ maybe) you should try to quit using (doc// found)
-						 \.)))
-  (make-local-variable 'whywant)
-  (setq whywant '( ((doc$ whysay) (doc// subj) might (doc$ want) (doc// obj) \?)
-		   (how does it feel to want \?)
-		   (why should (doc// subj) get (doc// obj) \?)
-		   (when did (doc// subj) first (doc$ want) (doc// obj) \?)
-		   ((doc$ areyou) obsessed with (doc// obj) \?)
-		   (why should i give (doc// obj) to (doc// subj) \?)
-		   (have you ever gotten (doc// obj) \?) ))
-  (make-local-variable 'canyou)
-  (setq canyou '((of course i can \.)
-		 (why should i \?)
-		 (what makes you think i would even want to \?)
-		 (i am the doctor\, i can do anything i damn please \.)
-		 (not really\, it\'s not up to me \.)
-		 (depends\, how important is it \?)
-		 (i could\, but i don\'t think it would be a wise thing to do \.)
-		 (can you \?)
-		 (maybe i can\, maybe i can\'t \.\.\.)
-		 (i don\'t think i should do that \.)))
-  (make-local-variable 'want)
-  (setq want '( (want) (desire) (wish) (want) (hope) ))
-  (make-local-variable 'shortlst)
-  (setq shortlst
-	'((can you elaborate on that \?)
-	  ((doc$ please) continue \.)
-	  (go on\, don\'t be afraid \.)
-	  (i need a little more detail please \.)
-	  (you\'re being a bit brief\, (doc$ please) go into detail \.)
-	  (can you be more explicit \?)
-	  (and \?)
-	  ((doc$ please) go into more detail \?)
-	  (you aren\'t being very talkative today\!)
-	  (is that all there is to it \?)
-	  (why must you respond so briefly \?)))
-
-  (make-local-variable 'famlst)
-  (setq famlst
-	'((tell me (doc$ something) about (doc// owner) family \.)
-	  (you seem to dwell on (doc// owner) family \.)
-	  ((doc$ areyou) hung up on (doc// owner) family \?)))
-  (make-local-variable 'huhlst)
-  (setq huhlst
-	'(((doc$ whysay)(doc// sent) \?)
-	  (is it because of (doc$ things) that you say (doc// sent) \?) ))
-  (make-local-variable 'longhuhlst)
-  (setq longhuhlst
-	'(((doc$ whysay) that \?)
-	  (i don\'t understand \.)
-	  ((doc$ thlst))
-	  ((doc$ areyou) (doc$ afraidof) that \?)))
-  (make-local-variable 'feelings-about)
-  (setq feelings-about
-	'((feelings about)
-	  (apprehensions toward)
-	  (thoughts on)
-	  (emotions toward)))
-  (make-local-variable 'random-adjective)
-  (setq random-adjective
-	'((vivid)
-	  (emotionally stimulating)
-	  (exciting)
-	  (boring)
-	  (interesting)
-	  (recent)
-	  (random)   ;How can we omit this?
-	  (unusual)
-	  (shocking)
-	  (embarrassing)))
-  (make-local-variable 'whysay)
-  (setq whysay
-	'((why do you say)
-	  (what makes you believe)
-	  (are you sure that)
-	  (do you really think)
-	  (what makes you think) ))
-  (make-local-variable 'isee)
-  (setq isee
-	'((i see \.\.\.)
-	  (yes\,)
-	  (i understand \.)
-	  (oh \.) ))
-  (make-local-variable 'please)
-  (setq please
-	'((please\,)
-	  (i would appreciate it if you would)
-	  (perhaps you could)
-	  (please\,)
-	  (would you please)
-	  (why don\'t you)
-	  (could you)))
-  (make-local-variable 'bye)
-  (setq bye
-	'((my secretary will send you a bill \.)
-	  (bye bye \.)
-	  (see ya \.)
-	  (ok\, talk to you some other time \.)
-	  (talk to you later \.)
-	  (ok\, have fun \.)
-	  (ciao \.)))
-  (make-local-variable 'something)
-  (setq something
-	'((something)
-	  (more)
-	  (how you feel)))
-  (make-local-variable 'thing)
-  (setq thing
-	'((your life)
-	  (your sex life)))
-  (make-local-variable 'things)
-  (setq things
-	'((your plans)
-	  (the people you hang around with)
-	  (problems at school)
-	  (any hobbies you have)
-	  (hangups you have)
-	  (your inhibitions)
-	  (some problems in your childhood)
-	  (some problems at home)))
-  (make-local-variable 'describe)
-  (setq describe
-	'((describe)
-	  (tell me about)
-	  (talk about)
-	  (discuss)
-	  (tell me more about)
-	  (elaborate on)))
-  (make-local-variable 'ibelieve)
-  (setq ibelieve
-	'((i believe) (i think) (i have a feeling) (it seems to me that)
-	  (it looks like)))
-  (make-local-variable 'problems)
-  (setq problems '( (problems)
-		    (inhibitions)
-		    (hangups)
-		    (difficulties)
-		    (anxieties)
-		    (frustrations) ))
-  (make-local-variable 'bother)
-  (setq bother
-	'((does it bother you that)
-	  (are you annoyed that)
-	  (did you ever regret)
-	  (are you sorry)
-	  (are you satisfied with the fact that)))
-  (make-local-variable 'machlst)
-  (setq machlst
-	'((you have your mind on (doc// found) \, it seems \.)
-	  (you think too much about  (doc// found) \.)
-	  (you should try taking your mind off of (doc// found)\.)
-	  (are you a computer hacker \?)))
-  (make-local-variable 'qlist)
-  (setq qlist
-	'((what do you think \?)
-	  (i\'ll ask the questions\, if you don\'t mind!)
-	  (i could ask the same thing myself \.)
-	  ((doc$ please) allow me to do the questioning \.)
-	  (i have asked myself that question many times \.)
-	  ((doc$ please) try to answer that question yourself \.)))
-  (make-local-variable 'foullst)
-  (setq foullst
-	'(((doc$ please) watch your tongue!)
-	  ((doc$ please) avoid such unwholesome thoughts \.)
-	  ((doc$ please) get your mind out of the gutter \.)
-	  (such lewdness is not appreciated \.)))
-  (make-local-variable 'deathlst)
-  (setq deathlst
-	'((this is not a healthy way of thinking \.)
-	  ((doc$ bother) you\, too\, may die someday \?)
-	  (i am worried by your obsession with this topic!)
-	  (did you watch a lot of crime and violence on television as a child \?))
-	)
-  (make-local-variable 'sexlst)
-  (setq sexlst
-	'(((doc$ areyou) (doc$ afraidof) sex \?)
-	  ((doc$ describe)(doc$ something) about your sexual history \.)
-	  ((doc$ please)(doc$ describe) your sex life \.\.\.)
-	  ((doc$ describe) your (doc$ feelings-about) your sexual partner \.)
-	  ((doc$ describe) your most (doc$ random-adjective) sexual experience \.)
-	  ((doc$ areyou) satisfied with (doc// lover) \.\.\. \?)))
-  (make-local-variable 'neglst)
-  (setq neglst
-	'((why not \?)
-	  ((doc$ bother) i ask that \?)
-	  (why not \?)
-	  (why not \?)
-	  (how come \?)
-	  ((doc$ bother) i ask that \?)))
-  (make-local-variable 'beclst)
-  (setq beclst '(
-		 (is it because (doc// sent) that you came to me \?)
-		 ((doc$ bother)(doc// sent) \?)
-		 (when did you first know that (doc// sent) \?)
-		 (is the fact that (doc// sent) the real reason \?)
-		 (does the fact that (doc// sent) explain anything else \?)
-		 ((doc$ areyou)(doc$ sure)(doc// sent) \? ) ))
-  (make-local-variable 'shortbeclst)
-  (setq shortbeclst '(
-		      ((doc$ bother) i ask you that \?)
-		      (that\'s not much of an answer!)
-		      ((doc$ inter) why won\'t you talk about it \?)
-		      (speak up!)
-		      ((doc$ areyou) (doc$ afraidof) talking about it \?)
-		      (don\'t be (doc$ afraidof) elaborating \.)
-		      ((doc$ please) go into more detail \.)))
-  (make-local-variable 'thlst)
-  (setq thlst '(
-		((doc$ maybe)(doc$ thing)(doc$ isrelated) this \.)
-		((doc$ maybe)(doc$ things)(doc$ arerelated) this \.)
-		(is it because of (doc$ things) that you are going through all this \?)
-		(how do you reconcile (doc$ things) \? )
-		((doc$ maybe) this (doc$ isrelated)(doc$ things) \?) ))
-  (make-local-variable 'remlst)
-  (setq remlst '( (earlier you said (doc$ history) \?)
-		  (you mentioned that (doc$ history) \?)
-		  ((doc$ whysay)(doc$ history) \? ) ))
-  (make-local-variable 'toklst)
-  (setq toklst
-	'((is this how you relax \?)
-	  (how long have you been smoking	grass \?)
-	  ((doc$ areyou) (doc$ afraidof) of being drawn to using harder stuff \?)))
-  (make-local-variable 'states)
-  (setq states
-	'((do you get (doc// found) often \?)
-	  (do you enjoy being (doc// found) \?)
-	  (what makes you (doc// found) \?)
-	  (how often (doc$ areyou)(doc// found) \?)
-	  (when were you last (doc// found) \?)))
-  (make-local-variable 'replist)
-  (setq replist
-	'((i . (you))
-	  (my . (your))
-	  (me . (you))
-	  (you . (me))
-	  (your . (my))
-	  (mine . (yours))
-	  (yours . (mine))
-	  (our . (your))
-	  (ours . (yours))
-	  (we . (you))
-	  (dunno . (do not know))
-;;	  (yes . ())
-	  (no\, . ())
-	  (yes\, . ())
-	  (ya . (i))
-	  (aint . (am not))
-	  (wanna . (want to))
-	  (gimme . (give me))
-	  (gotta . (have to))
-	  (gonna . (going to))
-	  (never . (not ever))
-	  (doesn\'t . (does not))
-	  (don\'t . (do not))
-	  (aren\'t . (are not))
-	  (isn\'t . (is not))
-	  (won\'t . (will not))
-	  (can\'t . (cannot))
-	  (haven\'t . (have not))
-	  (i\'m . (you are))
-	  (ourselves . (yourselves))
-	  (myself . (yourself))
-	  (yourself . (myself))
-	  (you\'re . (i am))
-	  (you\'ve . (i have))
-	  (i\'ve . (you have))
-	  (i\'ll . (you will))
-	  (you\'ll . (i shall))
-	  (i\'d . (you would))
-	  (you\'d . (i would))
-	  (here . (there))
-	  (please . ())
-	  (eh\, . ())
-	  (eh . ())
-	  (oh\, . ())
-	  (oh . ())
-	  (shouldn\'t . (should not))
-	  (wouldn\'t . (would not))
-	  (won\'t . (will not))
-	  (hasn\'t . (has not))))
-  (make-local-variable 'stallmanlst)
-  (setq stallmanlst '(
-		      ((doc$ describe) your (doc$ feelings-about) him \.)
-		      ((doc$ areyou) a friend of Stallman \?)
-		      ((doc$ bother) Stallman is (doc$ random-adjective) \?)
-		      ((doc$ ibelieve) you are (doc$ afraidof) him \.)))
-  (make-local-variable 'schoollst)
-  (setq schoollst '(
-		    ((doc$ describe) your (doc// found) \.)
-		    ((doc$ bother) your grades could (doc$ improve) \?)
-		    ((doc$ areyou) (doc$ afraidof) (doc// found) \?)
-		    ((doc$ maybe) this (doc$ isrelated) to your attitude \.)
-		    ((doc$ areyou) absent often \?)
-		    ((doc$ maybe) you should study (doc$ something) \.)))
-  (make-local-variable 'improve)
-  (setq improve '((improve) (be better) (be improved) (be higher)))
-  (make-local-variable 'elizalst)
-  (setq elizalst '(
-		   ((doc$ areyou) (doc$ sure) \?)
-		   ((doc$ ibelieve) you have (doc$ problems) with (doc// found) \.)
-		   ((doc$ whysay) (doc// sent) \?)))
-  (make-local-variable 'sportslst)
-  (setq sportslst '(
-		    (tell me (doc$ something) about (doc// found) \.)
-		    ((doc$ describe) (doc$ relation) (doc// found) \.)
-		    (do you find (doc// found) (doc$ random-adjective) \?)))
-  (make-local-variable 'mathlst)
-  (setq mathlst '(
-		  ((doc$ describe) (doc$ something) about math \.)
-		  ((doc$ maybe) your (doc$ problems) (doc$ arerelated) (doc// found) \.)
-		  (i don\'t know much (doc// found) \, but (doc$ continue)
-		     anyway \.)))
-  (make-local-variable 'zippylst)
-  (setq zippylst '(
-		   ((doc$ areyou) Zippy \?)
-		   ((doc$ ibelieve) you have some serious (doc$ problems) \.)
-		   ((doc$ bother) you are a pinhead \?)))
-  (make-local-variable 'chatlst)
-  (setq chatlst '(
-		  ((doc$ maybe) we could chat \.)
-		  ((doc$ please) (doc$ describe) (doc$ something) about chat mode \.)
-		  ((doc$ bother) our discussion is so (doc$ random-adjective) \?)))
-  (make-local-variable 'abuselst)
-  (setq abuselst '(
-		   ((doc$ please) try to be less abusive \.)
-		   ((doc$ describe) why you call me (doc// found) \.)
-		   (i\'ve had enough of you!)))
-  (make-local-variable 'abusewords)
-  (setq abusewords '(boring bozo clown clumsy cretin dumb dummy
-			    fool foolish gnerd gnurd idiot jerk
-			    lose loser louse lousy luse luser
-			    moron nerd nurd oaf oafish reek
-			    stink stupid tool toolish twit))
-  (make-local-variable 'howareyoulst)
-  (setq howareyoulst  '((how are you) (hows it going) (hows it going eh)
-			(how\'s it going) (how\'s it going eh) (how goes it)
-			(whats up) (whats new) (what\'s up) (what\'s new)
-			(howre you) (how\'re you) (how\'s everything)
-			(how is everything) (how do you do)
-			(how\'s it hanging) (que pasa)
-			(how are you doing) (what do you say)))
-  (make-local-variable 'whereoutp)
-  (setq whereoutp '( huh remem rthing ) )
-  (make-local-variable 'subj)
-  (setq subj nil)
-  (make-local-variable 'verb)
-  (setq verb nil)
-  (make-local-variable 'obj)
-  (setq obj nil)
-  (make-local-variable 'feared)
-  (setq feared nil)
-  (make-local-variable 'repetitive-shortness)
-  (setq repetitive-shortness '(0 . 0))
-  (make-local-variable '**mad**)
-  (setq **mad** nil)
-  (make-local-variable 'rms-flag)
-  (setq rms-flag nil)
-  (make-local-variable 'eliza-flag)
-  (setq eliza-flag nil)
-  (make-local-variable 'zippy-flag)
-  (setq zippy-flag nil)
-  (make-local-variable 'suicide-flag)
-  (setq suicide-flag nil)
-  (make-local-variable 'lover)
-  (setq lover '(your partner))
-  (make-local-variable 'bak)
-  (setq bak nil)
-  (make-local-variable 'lincount)
-  (setq lincount 0)
-  (make-local-variable '*print-upcase*)
-  (setq *print-upcase* nil)
-  (make-local-variable '*print-space*)
-  (setq *print-space* nil)
-  (make-local-variable 'howdyflag)
-  (setq howdyflag nil)
-  (make-local-variable 'object)
-  (setq object nil))
+  (set (make-local-variable 'doctor--typos)
+       (mapcar (lambda (x)
+		 (put (car x) 'doctor-correction  (cadr x))
+		 (put (cadr x) 'doctor-expansion (car (cddr x)))
+		 (car x))
+	       '((theyll they\'ll (they will))
+		 (theyre they\'re (they are))
+		 (hes he\'s (he is))
+		 (he7s he\'s (he is))
+		 (im i\'m (you are))
+		 (i7m i\'m (you are))
+		 (isa is\ a (is a))
+		 (thier their (their))
+		 (dont don\'t (do not))
+		 (don7t don\'t (do not))
+		 (you7re you\'re (i am))
+		 (you7ve you\'ve (i have))
+		 (you7ll you\'ll (i will)))))
+  (set (make-local-variable 'doctor-found) nil)
+  (set (make-local-variable 'doctor-owner) nil)
+  (set (make-local-variable 'doctor--history) nil)
+  (set (make-local-variable 'doctor--inter) '((well\,)
+				      (hmmm \.\.\.\ so\,)
+				      (so)
+				      (\.\.\.and)
+				      (then)))
+  (set (make-local-variable 'doctor--continue) '((continue)
+						 (proceed)
+						 (go on)
+						 (keep going)))
+  (set (make-local-variable 'doctor--relation)
+       '((your relationship with)
+	 (something you remember about)
+	 (your feelings toward)
+	 (some experiences you have had with)
+	 (how you feel about)))
+  (set (make-local-variable 'doctor--fears)
+       '(((doc$ doctor--whysay) you are (doc$ doctor--afraidof) (doc// doctor--feared) \?)
+	 (you seem terrified by (doc// doctor--feared) \.)
+	 (when did you first feel (doc$ doctor--afraidof) (doc// doctor--feared) \?)))
+  (set (make-local-variable 'doctor--sure) '((sure)
+					     (positive)
+					     (certain)
+					     (absolutely sure)))
+  (set (make-local-variable 'doctor--afraidof) '((afraid of)
+					 (frightened by)
+					 (scared of)))
+  (set (make-local-variable 'doctor--areyou) '((are you)
+				       (have you been)
+				       (have you been)))
+  (set (make-local-variable 'doctor--isrelated)
+       '((has something to do with)
+	 (is related to)
+	 (could be the reason for)
+	 (is caused by)
+	 (is because of)))
+  (set (make-local-variable 'doctor--arerelated) '((have something to do with)
+					   (are related to)
+					   (could have caused)
+					   (could be the reason for)
+					   (are caused by)
+					   (are because of)))
+  (set (make-local-variable 'doctor--moods)
+       '(((doc$ doctor--areyou) (doc// doctor-found) often \?)
+	 (what causes you to be (doc// doctor-found) \?)
+	 ((doc$ doctor--whysay) you are (doc// doctor-found) \?)))
+  (set (make-local-variable 'doctor--maybe) '((maybe)
+				      (perhaps)
+				      (possibly)))
+  (set (make-local-variable 'doctor--whatwhen) '((what happened when)
+						 (what would happen if)))
+  (set (make-local-variable 'doctor--hello) '((how do you do \?)
+				      (hello \.)
+				      (howdy!)
+				      (hello \.)
+				      (hi \.)
+				      (hi there \.)))
+  (set (make-local-variable 'doctor--drnk)
+       '((do you drink a lot of (doc// doctor-found) \?)
+	 (do you get drunk often \?)
+	 ((doc$ doctor--describe) your drinking habits \.)))
+  (set (make-local-variable 'doctor--drugs)
+       '((do you use (doc// doctor-found) often \?)
+	 ((doc$ doctor--areyou) addicted to (doc// doctor-found) \?)
+	 (do you realize that drugs can be very harmful \?)
+	 ((doc$ doctor--maybe) you should try to quit using (doc// doctor-found) \.)))
+  (set (make-local-variable 'doctor--whywant)
+       '(((doc$ doctor--whysay) (doc// doctor-subj) might (doc$ doctor--want) (doc// doctor-obj) \?)
+	 (how does it feel to want \?)
+	 (why should (doc// doctor-subj) get (doc// doctor-obj) \?)
+	 (when did (doc// doctor-subj) first (doc$ doctor--want) (doc// doctor-obj) \?)
+	 ((doc$ doctor--areyou) obsessed with (doc// doctor-obj) \?)
+	 (why should i give (doc// doctor-obj) to (doc// doctor-subj) \?)
+	 (have you ever gotten (doc// doctor-obj) \?)))
+  (set (make-local-variable 'doctor--canyou)
+       '((of course i can \.)
+	 (why should i \?)
+	 (what makes you think i would even want to \?)
+	 (i am the doctor\, i can do anything i damn please \.)
+	 (not really\, it\'s not up to me \.)
+	 (depends\, how important is it \?)
+	 (i could\, but i don\'t think it would be a wise thing to do \.)
+	 (can you \?)
+	 (maybe i can\, maybe i can\'t \.\.\.)
+	 (i don\'t think i should do that \.)))
+  (set (make-local-variable 'doctor--want) '((want) (desire) (wish) (want) (hope)))
+  (set (make-local-variable 'doctor--shortlst)
+       '((can you elaborate on that \?)
+	 ((doc$ doctor--please) continue \.)
+	 (go on\, don\'t be afraid \.)
+	 (i need a little more detail please \.)
+	 (you\'re being a bit brief\, (doc$ doctor--please) go into detail \.)
+	 (can you be more explicit \?)
+	 (and \?)
+	 ((doc$ doctor--please) go into more detail \?)
+	 (you aren\'t being very talkative today\!)
+	 (is that all there is to it \?)
+	 (why must you respond so briefly \?)))
+  (set (make-local-variable 'doctor--famlst)
+       '((tell me (doc$ doctor--something) about (doc// doctor-owner) family \.)
+	 (you seem to dwell on (doc// doctor-owner) family \.)
+	 ((doc$ doctor--areyou) hung up on (doc// doctor-owner) family \?)))
+  (set (make-local-variable 'doctor--huhlst)
+       '(((doc$ doctor--whysay)(doc// doctor-sent) \?)
+	 (is it because of (doc$ doctor--things) that you say (doc// doctor-sent) \?)))
+  (set (make-local-variable 'doctor--longhuhlst)
+       '(((doc$ doctor--whysay) that \?)
+	 (i don\'t understand \.)
+	 ((doc$ doctor--thlst))
+	 ((doc$ doctor--areyou) (doc$ doctor--afraidof) that \?)))
+  (set (make-local-variable 'doctor--feelings-about) '((feelings about)
+					       (apprehensions toward)
+					       (thoughts on)
+					       (emotions toward)))
+  (set (make-local-variable 'doctor--random-adjective)
+       '((vivid)
+	 (emotionally stimulating)
+	 (exciting)
+	 (boring)
+	 (interesting)
+	 (recent)
+	 (random) ; how can we omit this?
+	 (unusual)
+	 (shocking)
+	 (embarrassing)))
+  (set (make-local-variable 'doctor--whysay) '((why do you say)
+				       (what makes you believe)
+				       (are you sure that)
+				       (do you really think)
+				       (what makes you think)))
+  (set (make-local-variable 'doctor--isee) '((i see \.\.\.)
+				     (yes\,)
+				     (i understand \.)
+				     (oh \.) ))
+  (set (make-local-variable 'doctor--please) '((please\,)
+				       (i would appreciate it if you would)
+				       (perhaps you could)
+				       (please\,)
+				       (would you please)
+				       (why don\'t you)
+				       (could you)))
+  (set (make-local-variable 'doctor--bye)
+       '((my secretary will send you a bill \.)
+	 (bye bye \.)
+	 (see ya \.)
+	 (ok\, talk to you some other time \.)
+	 (talk to you later \.)
+	 (ok\, have fun \.)
+	 (ciao \.)))
+  (set (make-local-variable 'doctor--something) '((something)
+						  (more)
+						  (how you feel)))
+  (set (make-local-variable 'doctor--thing) '((your life)
+				      (your sex life)))
+  (set (make-local-variable 'doctor--things) '((your plans)
+				       (the people you hang around with)
+				       (problems at school)
+				       (any hobbies you have)
+				       (hangups you have)
+				       (your inhibitions)
+				       (some problems in your childhood)
+				       (some problems at home)))
+  (set (make-local-variable 'doctor--describe) '((describe)
+					 (tell me about)
+					 (talk about)
+					 (discuss)
+					 (tell me more about)
+					 (elaborate on)))
+  (set (make-local-variable 'doctor--ibelieve)
+       '((i believe) (i think) (i have a feeling) (it seems to me that)
+	 (it looks like)))
+  (set (make-local-variable 'doctor--problems) '((problems)
+					 (inhibitions)
+					 (hangups)
+					 (difficulties)
+					 (anxieties)
+					 (frustrations)))
+  (set (make-local-variable 'doctor--bother) '((does it bother you that)
+				       (are you annoyed that)
+				       (did you ever regret)
+				       (are you sorry)
+				       (are you satisfied with the fact that)))
+  (set (make-local-variable 'doctor--machlst)
+       '((you have your mind on (doc// doctor-found) \, it seems \.)
+	 (you think too much about  (doc// doctor-found) \.)
+	 (you should try taking your mind off of (doc// doctor-found)\.)
+	 (are you a computer hacker \?)))
+  (set (make-local-variable 'doctor--qlist)
+       '((what do you think \?)
+	 (i\'ll ask the questions\, if you don\'t mind!)
+	 (i could ask the same thing myself \.)
+	 ((doc$ doctor--please) allow me to do the questioning \.)
+	 (i have asked myself that question many times \.)
+	 ((doc$ doctor--please) try to answer that question yourself \.)))
+  (set (make-local-variable 'doctor--foullst)
+       '(((doc$ doctor--please) watch your tongue!)
+	 ((doc$ doctor--please) avoid such unwholesome thoughts \.)
+	 ((doc$ doctor--please) get your mind out of the gutter \.)
+	 (such lewdness is not appreciated \.)))
+  (set (make-local-variable 'doctor--deathlst)
+       '((this is not a healthy way of thinking \.)
+	 ((doc$ doctor--bother) you\, too\, may die someday \?)
+	 (i am worried by your obsession with this topic!)
+	 (did you watch a lot of crime and violence on television as a child \?)))
+  (set (make-local-variable 'doctor--sexlst)
+       '(((doc$ doctor--areyou) (doc$ doctor--afraidof) sex \?)
+	 ((doc$ doctor--describe)(doc$ doctor--something) about your sexual history \.)
+	 ((doc$ doctor--please)(doc$ doctor--describe) your sex life \.\.\.)
+	 ((doc$ doctor--describe) your (doc$ doctor--feelings-about) your sexual partner \.)
+	 ((doc$ doctor--describe) your most (doc$ doctor--random-adjective) sexual experience \.)
+	 ((doc$ doctor--areyou) satisfied with (doc// doctor--lover) \.\.\. \?)))
+  (set (make-local-variable 'doctor--neglst) '((why not \?)
+				       ((doc$ doctor--bother) i ask that \?)
+				       (why not \?)
+				       (why not \?)
+				       (how come \?)
+				       ((doc$ doctor--bother) i ask that \?)))
+  (set (make-local-variable 'doctor--beclst)
+       '((is it because (doc// doctor-sent) that you came to me \?)
+	 ((doc$ doctor--bother)(doc// doctor-sent) \?)
+	 (when did you first know that (doc// doctor-sent) \?)
+	 (is the fact that (doc// doctor-sent) the real reason \?)
+	 (does the fact that (doc// doctor-sent) explain anything else \?)
+	 ((doc$ doctor--areyou)(doc$ doctor--sure)(doc// doctor-sent) \? )))
+  (set (make-local-variable 'doctor--shortbeclst)
+   '(((doc$ doctor--bother) i ask you that \?)
+     (that\'s not much of an answer!)
+     ((doc$ doctor--inter) why won\'t you talk about it \?)
+     (speak up!)
+     ((doc$ doctor--areyou) (doc$ doctor--afraidof) talking about it \?)
+     (don\'t be (doc$ doctor--afraidof) elaborating \.)
+     ((doc$ doctor--please) go into more detail \.)))
+  (set (make-local-variable 'doctor--thlst)
+       '(((doc$ doctor--maybe)(doc$ doctor--thing)(doc$ doctor--isrelated) this \.)
+	 ((doc$ doctor--maybe)(doc$ doctor--things)(doc$ doctor--arerelated) this \.)
+	 (is it because of (doc$ doctor--things) that you are going through all this \?)
+	 (how do you reconcile (doc$ doctor--things) \? )
+	 ((doc$ doctor--maybe) this (doc$ doctor--isrelated)(doc$ doctor--things) \?)))
+  (set (make-local-variable 'doctor--remlst)
+       '((earlier you said (doc$ doctor--history) \?)
+	 (you mentioned that (doc$ doctor--history) \?)
+	 ((doc$ doctor--whysay)(doc$ doctor--history) \? )))
+  (set (make-local-variable 'doctor--toklst)
+       '((is this how you relax \?)
+	 (how long have you been smoking	grass \?)
+	 ((doc$ doctor--areyou) (doc$ doctor--afraidof) of being drawn to using harder stuff \?)))
+  (set (make-local-variable 'doctor--states)
+       '((do you get (doc// doctor-found) often \?)
+	 (do you enjoy being (doc// doctor-found) \?)
+	 (what makes you (doc// doctor-found) \?)
+	 (how often (doc$ doctor--areyou)(doc// doctor-found) \?)
+	 (when were you last (doc// doctor-found) \?)))
+  (set (make-local-variable 'doctor--replist) '((i . (you))
+					(my . (your))
+					(me . (you))
+					(you . (me))
+					(your . (my))
+					(mine . (yours))
+					(yours . (mine))
+					(our . (your))
+					(ours . (yours))
+					(we . (you))
+					(dunno . (do not know))
+					;;	  (yes . ())
+					(no\, . ())
+					(yes\, . ())
+					(ya . (i))
+					(aint . (am not))
+					(wanna . (want to))
+					(gimme . (give me))
+					(gotta . (have to))
+					(gonna . (going to))
+					(never . (not ever))
+					(doesn\'t . (does not))
+					(don\'t . (do not))
+					(aren\'t . (are not))
+					(isn\'t . (is not))
+					(won\'t . (will not))
+					(can\'t . (cannot))
+					(haven\'t . (have not))
+					(i\'m . (you are))
+					(ourselves . (yourselves))
+					(myself . (yourself))
+					(yourself . (myself))
+					(you\'re . (i am))
+					(you\'ve . (i have))
+					(i\'ve . (you have))
+					(i\'ll . (you will))
+					(you\'ll . (i shall))
+					(i\'d . (you would))
+					(you\'d . (i would))
+					(here . (there))
+					(please . ())
+					(eh\, . ())
+					(eh . ())
+					(oh\, . ())
+					(oh . ())
+					(shouldn\'t . (should not))
+					(wouldn\'t . (would not))
+					(won\'t . (will not))
+					(hasn\'t . (has not))))
+  (set (make-local-variable 'doctor--stallmanlst)
+       '(((doc$ doctor--describe) your (doc$ doctor--feelings-about) him \.)
+	 ((doc$ doctor--areyou) a friend of Stallman \?)
+	 ((doc$ doctor--bother) Stallman is (doc$ doctor--random-adjective) \?)
+	 ((doc$ doctor--ibelieve) you are (doc$ doctor--afraidof) him \.)))
+  (set (make-local-variable 'doctor--schoollst)
+       '(((doc$ doctor--describe) your (doc// doctor-found) \.)
+	 ((doc$ doctor--bother) your grades could (doc$ doctor--improve) \?)
+	 ((doc$ doctor--areyou) (doc$ doctor--afraidof) (doc// doctor-found) \?)
+	 ((doc$ doctor--maybe) this (doc$ doctor--isrelated) to your attitude \.)
+	 ((doc$ doctor--areyou) absent often \?)
+	 ((doc$ doctor--maybe) you should study (doc$ doctor--something) \.)))
+  (set (make-local-variable 'doctor--improve)
+       '((improve) (be better) (be improved) (be higher)))
+  (set (make-local-variable 'doctor--elizalst)
+       '(((doc$ doctor--areyou) (doc$ doctor--sure) \?)
+	 ((doc$ doctor--ibelieve) you have (doc$ doctor--problems) with (doc// doctor-found) \.)
+	 ((doc$ doctor--whysay) (doc// doctor-sent) \?)))
+  (set (make-local-variable 'doctor--sportslst)
+       '((tell me (doc$ doctor--something) about (doc// doctor-found) \.)
+	 ((doc$ doctor--describe) (doc$ doctor--relation) (doc// doctor-found) \.)
+	 (do you find (doc// doctor-found) (doc$ doctor--random-adjective) \?)))
+  (set (make-local-variable 'doctor--mathlst)
+       '(((doc$ doctor--describe) (doc$ doctor--something) about math \.)
+	 ((doc$ doctor--maybe) your (doc$ doctor--problems) (doc$ doctor--arerelated) (doc// doctor-found) \.)
+	 (i don\'t know much (doc// doctor-found) \, but (doc$ doctor--continue)
+	    anyway \.)))
+  (set (make-local-variable 'doctor--zippylst)
+       '(((doc$ doctor--areyou) Zippy \?)
+	 ((doc$ doctor--ibelieve) you have some serious (doc$ doctor--problems) \.)
+	 ((doc$ doctor--bother) you are a pinhead \?)))
+  (set (make-local-variable 'doctor--chatlst)
+       '(((doc$ doctor--maybe) we could chat \.)
+	 ((doc$ doctor--please) (doc$ doctor--describe) (doc$ doctor--something) about chat mode \.)
+	 ((doc$ doctor--bother) our discussion is so (doc$ doctor--random-adjective) \?)))
+  (set (make-local-variable 'doctor--abuselst)
+       '(((doc$ doctor--please) try to be less abusive \.)
+	 ((doc$ doctor--describe) why you call me (doc// doctor-found) \.)
+	 (i\'ve had enough of you!)))
+  (set (make-local-variable 'doctor--abusewords)
+       '(boring bozo clown clumsy cretin dumb dummy
+		fool foolish gnerd gnurd idiot jerk
+		lose loser louse lousy luse luser
+		moron nerd nurd oaf oafish reek
+		stink stupid tool toolish twit))
+  (set (make-local-variable 'doctor--howareyoulst)
+       '((how are you) (hows it going) (hows it going eh)
+	 (how\'s it going) (how\'s it going eh) (how goes it)
+	 (whats up) (whats new) (what\'s up) (what\'s new)
+	 (howre you) (how\'re you) (how\'s everything)
+	 (how is everything) (how do you do)
+	 (how\'s it hanging) (que pasa)
+	 (how are you doing) (what do you say)))
+  (set (make-local-variable 'doctor--whereoutp) '(huh remem rthing))
+  (set (make-local-variable 'doctor-subj) nil)
+  (set (make-local-variable 'doctor-verb) nil)
+  (set (make-local-variable 'doctor-obj) nil)
+  (set (make-local-variable 'doctor--feared) nil)
+  (set (make-local-variable 'doctor--repetitive-shortness) '(0 . 0))
+  (set (make-local-variable 'doctor--**mad**) nil)
+  (set (make-local-variable 'doctor--rms-flag) nil)
+  (set (make-local-variable 'doctor--eliza-flag) nil)
+  (set (make-local-variable 'doctor--zippy-flag) nil)
+  (set (make-local-variable 'doctor--suicide-flag) nil)
+  (set (make-local-variable 'doctor--lover) '(your partner))
+  (set (make-local-variable 'doctor--bak) nil)
+  (set (make-local-variable 'doctor--lincount) 0)
+  (set (make-local-variable 'doctor--*print-upcase*) nil)
+  (set (make-local-variable 'doctor--*print-space*) nil)
+  (set (make-local-variable 'doctor--howdyflag) nil)
+  (set (make-local-variable 'doctor-object) nil))
 
 ;; Define equivalence classes of words that get treated alike.
 
 (defun doctor-meaning (x) (get x 'doctor-meaning))
 
 (defmacro doctor-put-meaning (symb val)
-    "Store the base meaning of a word on the property list."
-    (list 'put (list 'quote symb) ''doctor-meaning val))
+  "Store the base meaning of a word on the property list."
+  `(put ',symb 'doctor-meaning ,val))
 
 (doctor-put-meaning howdy 'howdy)
 (doctor-put-meaning hi 'howdy)
@@ -855,10 +836,10 @@
   (interactive)
   (let ((sent (doctor-readin)))
     (insert "\n")
-    (setq lincount (1+ lincount))
+    (setq doctor--lincount (1+ doctor--lincount))
     (doctor-doc sent)
     (insert "\n")
-    (setq bak sent)))
+    (setq doctor--bak sent)))
 
 (defun doctor-readin nil
   "Read a sentence.  Return it as a list of words."
@@ -878,70 +859,70 @@
 
 ;; Main processing function for sentences that have been read.
 
-(defun doctor-doc (sent)
+(defun doctor-doc (doctor-sent)
   (cond
-   ((equal sent '(foo))
-    (doctor-type '(bar! (doc$ please)(doc$ continue) \.)))
-   ((member sent howareyoulst)
-    (doctor-type '(i\'m ok \.  (doc$ describe) yourself \.)))
-   ((or (member sent '((good bye) (see you later) (i quit) (so long)
+   ((equal doctor-sent '(foo))
+    (doctor-type '(bar! (doc$ doctor--please)(doc$ doctor--continue) \.)))
+   ((member doctor-sent doctor--howareyoulst)
+    (doctor-type '(i\'m ok \.  (doc$ doctor--describe) yourself \.)))
+   ((or (member doctor-sent '((good bye) (see you later) (i quit) (so long)
 		       (go away) (get lost)))
-	(memq (car sent)
+	(memq (car doctor-sent)
 	      '(bye halt break quit done exit goodbye
 		    bye\, stop pause goodbye\, stop pause)))
-    (doctor-type (doc$ bye)))
-   ((and (eq (car sent) 'you)
-	 (memq (cadr sent) abusewords))
-    (setq found (cadr sent))
-    (doctor-type (doc$ abuselst)))
-   ((eq (car sent) 'whatmeans)
-    (doctor-def (cadr sent)))
-   ((equal sent '(parse))
-    (doctor-type (list  'subj '= subj ",  "
-			'verb '= verb "\n"
-			'object 'phrase '= obj ","
-			'noun 'form '=  object "\n"
-			'current 'keyword 'is found
+    (doctor-type (doc$ doctor--bye)))
+   ((and (eq (car doctor-sent) 'you)
+	 (memq (cadr doctor-sent) doctor--abusewords))
+    (setq doctor-found (cadr doctor-sent))
+    (doctor-type (doc$ doctor--abuselst)))
+   ((eq (car doctor-sent) 'whatmeans)
+    (doctor-def (cadr doctor-sent)))
+   ((equal doctor-sent '(parse))
+    (doctor-type (list  'subj '= doctor-subj ",  "
+			'verb '= doctor-verb "\n"
+			'object 'phrase '= doctor-obj ","
+			'noun 'form '=  doctor-object "\n"
+			'current 'keyword 'is doctor-found
 			", "
 			'most 'recent 'possessive
-			'is owner "\n"
+			'is doctor-owner "\n"
 			'sentence 'used 'was
 			"..."
-			'(doc// bak))))
-   ((memq (car sent) '(are is do has have how when where who why))
-    (doctor-type (doc$ qlist)))
-   ;;   ((eq (car sent) 'forget)
-   ;;    (set (cadr sent) nil)
-   ;;    (doctor-type '((doc$ isee)(doc$ please)
-   ;;     (doc$ continue)\.)))
+			'(doc// doctor--bak))))
+   ((memq (car doctor-sent) '(are is do has have how when where who why))
+    (doctor-type (doc$ doctor--qlist)))
+   ;;   ((eq (car doctor-sent) 'forget)
+   ;;    (set (cadr doctor-sent) nil)
+   ;;    (doctor-type '((doc$ doctor--isee)(doc$ doctor--please)
+   ;;     (doc$ doctor--continue)\.)))
    (t
-    (if (doctor-defq sent) (doctor-define sent found))
-    (if (> (length sent) 12)(setq sent (doctor-shorten sent)))
-    (setq sent (doctor-correct-spelling (doctor-replace sent replist)))
-    (cond ((and (not (memq 'me sent))(not (memq 'i sent))
-		(memq 'am sent))
-	   (setq sent (doctor-replace sent '((am . (are)))))))
-    (cond ((equal (car sent) 'yow) (doctor-zippy))
-	  ((< (length sent) 2)
-	   (cond ((eq (doctor-meaning (car sent)) 'howdy)
+    (if (doctor-defq doctor-sent) (doctor-define doctor-sent doctor-found))
+    (if (> (length doctor-sent) 12)(setq doctor-sent (doctor-shorten doctor-sent)))
+    (setq doctor-sent (doctor-correct-spelling (doctor-replace doctor-sent doctor--replist)))
+    (cond ((and (not (memq 'me doctor-sent))(not (memq 'i doctor-sent))
+		(memq 'am doctor-sent))
+	   (setq doctor-sent (doctor-replace doctor-sent '((am . (are)))))))
+    (cond ((equal (car doctor-sent) 'yow) (doctor-zippy))
+	  ((< (length doctor-sent) 2)
+	   (cond ((eq (doctor-meaning (car doctor-sent)) 'howdy)
 		  (doctor-howdy))
 		 (t (doctor-short))))
 	  (t
-	   (if (memq 'am sent)
-	       (setq sent (doctor-replace sent '((me . (i))))))
-	   (setq sent (doctor-fixup sent))
-	   (if (and (eq (car sent) 'do) (eq (cadr sent) 'not))
+	   (if (memq 'am doctor-sent)
+	       (setq doctor-sent (doctor-replace doctor-sent '((me . (i))))))
+	   (setq doctor-sent (doctor-fixup doctor-sent))
+	   (if (and (eq (car doctor-sent) 'do) (eq (cadr doctor-sent) 'not))
 	       (cond ((zerop (random 3))
-		      (doctor-type '(are you (doc$ afraidof) that \?)))
+		      (doctor-type '(are you (doc$ doctor--afraidof) that \?)))
 		     ((zerop (random 2))
 		      (doctor-type '(don\'t tell me what to do \. i am the
 					    doctor here!))
 		      (doctor-rthing))
 		     (t
-		      (doctor-type '((doc$ whysay) that i shouldn\'t
-				     (cddr sent)
+		      (doctor-type '((doc$ doctor--whysay) that i shouldn\'t
+				     (cddr doctor-sent)
 				     \?))))
-	     (doctor-go (doctor-wherego sent))))))))
+	     (doctor-go (doctor-wherego doctor-sent))))))))
 
 ;; Things done to process sentences once read.
 
@@ -949,8 +930,9 @@
   "Correct the spelling and expand each word in sentence."
   (if sent
       (apply 'append (mapcar (lambda (word)
-				(if (memq word typos)
-				    (get (get word 'doctor-correction) 'doctor-expansion)
+				(if (memq word doctor--typos)
+				    (get (get word 'doctor-correction)
+					 'doctor-expansion)
 				  (list word)))
 			     sent))))
 
@@ -972,33 +954,32 @@
 (defun doctor-define (sent found)
   (doctor-svo sent found 1 nil)
   (and
-   (doctor-nounp subj)
-   (not (doctor-pronounp subj))
-   subj
-   (doctor-meaning object)
-   (put subj 'doctor-meaning (doctor-meaning object))
+   (doctor-nounp doctor-subj)
+   (not (doctor-pronounp doctor-subj))
+   doctor-subj
+   (doctor-meaning doctor-object)
+   (put doctor-subj 'doctor-meaning (doctor-meaning doctor-object))
    t))
 
 (defun doctor-defq (sent)
-  "Set global var FOUND to first keyword found in sentence SENT."
-  (setq found nil)
+  "Set global var DOCTOR-FOUND to first keyword found in sentence SENT."
+  (setq doctor-found nil)
   (let ((temp '(means applies mean refers refer related
 		      similar defined associated linked like same)))
     (while temp
 	   (if (memq (car temp) sent)
-	       (setq found (car temp)
+	       (setq doctor-found (car temp)
 		     temp nil)
 	       (setq temp (cdr temp)))))
-  found)
+  doctor-found)
 
 (defun doctor-def (x)
-  (progn
-   (doctor-type (list 'the 'word x 'means (doctor-meaning x) 'to 'me))
-   nil))
+  (doctor-type (list 'the 'word x 'means (doctor-meaning x) 'to 'me))
+  nil)
 
 (defun doctor-forget ()
   "Delete the last element of the history list."
-  (setq history (reverse (cdr (reverse history)))))
+  (setq doctor--history (reverse (cdr (reverse doctor--history)))))
 
 (defun doctor-query (x)
   "Prompt for a line of input from the minibuffer until a noun or verb is seen.
@@ -1026,16 +1007,16 @@
 
 (defun doctor-subjsearch (sent key type)
   "Search for the subject of a sentence SENT, looking for the noun closest
-to and preceding KEY by at least TYPE words.  Set global variable subj to
+to and preceding KEY by at least TYPE words.  Set global variable doctor-subj to
 the subject noun, and return the portion of the sentence following it."
   (let ((i (- (length sent) (length (memq key sent)) type)))
     (while (and (> i -1) (not (doctor-nounp (nth i sent))))
       (setq i (1- i)))
     (cond ((> i -1)
-	   (setq subj (nth i sent))
+	   (setq doctor-subj (nth i sent))
 	   (nthcdr (1+ i) sent))
 	  (t
-	   (setq subj 'you)
+	   (setq doctor-subj 'you)
 	   nil))))
 
 (defun doctor-nounp (x)
@@ -1149,12 +1130,12 @@
 	  (t 'something))))
 
 (defun doctor-getnoun (x)
-  (cond ((null x)(setq object 'something))
-	((atom x)(setq object x))
+  (cond ((null x)(setq doctor-object 'something))
+	((atom x)(setq doctor-object x))
 	((eq (length x) 1)
-	 (setq object (cond
-		       ((doctor-nounp (setq object (car x))) object)
-		       (t (doctor-query object)))))
+	 (setq doctor-object (cond
+		       ((doctor-nounp (setq doctor-object (car x))) doctor-object)
+		       (t (doctor-query doctor-object)))))
 	((eq (car x) 'to)
 	 (doctor-build 'to\  (doctor-getnoun (cdr x))))
 	((doctor-prepp (car x))
@@ -1170,7 +1151,7 @@
 						   (car x) (car x))))))
 				     " ")
 		       (doctor-getnoun (cdr x))))
-	(t (setq object (car x))
+	(t (setq doctor-object (car x))
 	   (doctor-build (doctor-build (car x) " ") (doctor-getnoun (cdr x))))
 	))
 
@@ -1238,9 +1219,9 @@
 		  under underneath with without)))
 
 (defun doctor-remember (thing)
-  (cond ((null history)
-	 (setq history (list thing)))
-	(t (setq history (append history (list thing))))))
+  (cond ((null doctor--history)
+	 (setq doctor--history (list thing)))
+	(t (setq doctor--history (append doctor--history (list thing))))))
 
 (defun doctor-type (x)
   (setq x (doctor-fix-2 x))
@@ -1317,57 +1298,58 @@
 element pair in RLIST."
   (apply 'append
 	 (mapcar
-	  (function
 	   (lambda (x)
 	     (cdr (or (assq x rlist)   ; either find a replacement
-		      (list x x)))))   ; or fake an identity mapping
-	  sent)))
+		      (list x x))))    ; or fake an identity mapping
+	   sent)))
 
 (defun doctor-wherego (sent)
-  (cond ((null sent)(doc$ whereoutp))
+  (cond ((null sent)(doc$ doctor--whereoutp))
 	((null (doctor-meaning (car sent)))
 	 (doctor-wherego (cond ((zerop (random 2))
 				(reverse (cdr sent)))
 			       (t (cdr sent)))))
 	(t
-	 (setq found (car sent))
+	 (setq doctor-found (car sent))
 	 (doctor-meaning (car sent)))))
 
 (defun doctor-svo (sent key type mem)
   "Find subject, verb and object in sentence SENT with focus on word KEY.
 TYPE is number of words preceding KEY to start looking for subject.
 MEM is t if results are to be put on Doctor's memory stack.
-Return in the global variables SUBJ, VERB and OBJECT."
+Return in the global variables DOCTOR-SUBJ, DOCTOR-VERB, DOCTOR-OBJECT,
+and DOCTOR-OBJ."
   (let ((foo (doctor-subjsearch sent key type)))
     (or foo
 	(setq foo sent
 	      mem nil))
     (while (and (null (doctor-verbp (car foo))) (cdr foo))
       (setq foo (cdr foo)))
-    (setq verb (car foo))
-    (setq obj (doctor-getnoun (cdr foo)))
-    (cond ((eq object 'i)(setq object 'me))
-	  ((eq subj 'me)(setq subj 'i)))
-    (cond (mem (doctor-remember (list subj verb obj))))))
+    (setq doctor-verb (car foo))
+    (setq doctor-obj (doctor-getnoun (cdr foo)))
+    (cond ((eq doctor-object 'i)(setq doctor-object 'me))
+	  ((eq doctor-subj 'me)(setq doctor-subj 'i)))
+    (cond (mem (doctor-remember (list doctor-subj doctor-verb doctor-obj))))))
 
 (defun doctor-possess (sent key)
   "Set possessive in SENT for keyword KEY.
-Hack on previous word, setting global variable OWNER to correct result."
+Hack on previous word, setting global variable DOCTOR-OWNER to correct result."
   (let* ((i (- (length sent) (length (memq key sent)) 1))
 	 (prev (if (< i 0) 'your
 		 (nth i sent))))
-    (setq owner (if (or (doctor-possessivepronounp prev)
-			(string-equal "s"
-				      (substring (doctor-make-string prev)
-						 -1)))
-		    prev
-		  'your))))
+    (setq doctor-owner
+	  (if (or (doctor-possessivepronounp prev)
+		  (string-equal "s"
+				(substring (doctor-make-string prev)
+					   -1)))
+	      prev
+	    'your))))
 
 ;; Output of replies.
 
 (defun doctor-txtype (ans)
   "Output to buffer a list of symbols or strings as a sentence."
-  (setq *print-upcase* t *print-space* nil)
+  (setq doctor--*print-upcase* t doctor--*print-space* nil)
   (mapc 'doctor-type-symbol ans)
   (insert "\n"))
 
@@ -1375,20 +1357,18 @@
   "Output a symbol to the buffer with some fancy case and spacing hacks."
   (setq word (doctor-make-string word))
   (if (string-equal word "i") (setq word "I"))
-  (if *print-upcase*
-      (progn
-	(setq word (capitalize word))
-	(if *print-space*
-	    (insert " "))))
+  (when doctor--*print-upcase*
+    (setq word (capitalize word))
+    (if doctor--*print-space* (insert " ")))
   (cond ((or (string-match "^[.,;:?! ]" word)
-	     (not *print-space*))
+	     (not doctor--*print-space*))
 	 (insert word))
 	(t (insert ?\s word)))
   (and auto-fill-function
        (> (current-column) fill-column)
        (apply auto-fill-function nil))
-  (setq *print-upcase* (string-match "[.?!]$" word)
-	*print-space* t))
+  (setq doctor--*print-upcase* (string-match "[.?!]$" word)
+	doctor--*print-space* t))
 
 (defun doctor-build (str1 str2)
   "Make a symbol out of the concatenation of the two non-list arguments."
@@ -1426,220 +1406,219 @@
   (funcall (intern (concat "doctor-" (doctor-make-string destination)))))
 
 (defun doctor-desire1 ()
-  (doctor-go (doc$ whereoutp)))
+  (doctor-go (doc$ doctor--whereoutp)))
 
 (defun doctor-huh ()
-  (cond ((< (length sent) 9) (doctor-type (doc$ huhlst)))
-	(t (doctor-type (doc$ longhuhlst)))))
+  (cond ((< (length doctor-sent) 9) (doctor-type (doc$ doctor--huhlst)))
+	(t (doctor-type (doc$ doctor--longhuhlst)))))
 
-(defun doctor-rthing () (doctor-type (doc$ thlst)))
+(defun doctor-rthing () (doctor-type (doc$ doctor--thlst)))
 
-(defun doctor-remem () (cond ((null history)(doctor-huh))
-			     ((doctor-type (doc$ remlst)))))
+(defun doctor-remem () (cond ((null doctor--history)(doctor-huh))
+			     ((doctor-type (doc$ doctor--remlst)))))
 
 (defun doctor-howdy ()
-  (cond ((not howdyflag)
-	 (doctor-type '((doc$ hello) what brings you to see me \?))
-	 (setq howdyflag t))
+  (cond ((not doctor--howdyflag)
+	 (doctor-type '((doc$ doctor--hello) what brings you to see me \?))
+	 (setq doctor--howdyflag t))
 	(t
-	 (doctor-type '((doc$ ibelieve) we\'ve introduced ourselves already \.))
-	 (doctor-type '((doc$ please) (doc$ describe) (doc$ things) \.)))))
+	 (doctor-type '((doc$ doctor--ibelieve) we\'ve introduced ourselves already \.))
+	 (doctor-type '((doc$ doctor--please) (doc$ doctor--describe) (doc$ doctor--things) \.)))))
 
 (defun doctor-when ()
-  (cond ((< (length (memq found sent)) 3)(doctor-short))
+  (cond ((< (length (memq doctor-found doctor-sent)) 3)(doctor-short))
 	(t
-	 (setq sent (cdr (memq found sent)))
-	 (setq sent (doctor-fixup sent))
-	 (doctor-type '((doc$ whatwhen)(doc// sent) \?)))))
+	 (setq doctor-sent (cdr (memq doctor-found doctor-sent)))
+	 (setq doctor-sent (doctor-fixup doctor-sent))
+	 (doctor-type '((doc$ doctor--whatwhen)(doc// doctor-sent) \?)))))
 
 (defun doctor-conj ()
-  (cond ((< (length (memq found sent)) 4)(doctor-short))
+  (cond ((< (length (memq doctor-found doctor-sent)) 4)(doctor-short))
 	(t
-	 (setq sent (cdr (memq found sent)))
-	 (setq sent (doctor-fixup sent))
-	 (cond ((eq (car sent) 'of)
-		(doctor-type '(are you (doc$ sure) that is the real reason \?))
-		(setq things (cons (cdr sent) things)))
+	 (setq doctor-sent (cdr (memq doctor-found doctor-sent)))
+	 (setq doctor-sent (doctor-fixup doctor-sent))
+	 (cond ((eq (car doctor-sent) 'of)
+		(doctor-type '(are you (doc$ doctor--sure) that is the real reason \?))
+		(setq doctor--things (cons (cdr doctor-sent) doctor--things)))
 	       (t
-		(doctor-remember sent)
-		(doctor-type (doc$ beclst)))))))
+		(doctor-remember doctor-sent)
+		(doctor-type (doc$ doctor--beclst)))))))
 
 (defun doctor-short ()
-  (cond ((= (car repetitive-shortness) (1- lincount))
-	 (rplacd repetitive-shortness
-		 (1+ (cdr repetitive-shortness))))
+  (cond ((= (car doctor--repetitive-shortness) (1- doctor--lincount))
+	 (rplacd doctor--repetitive-shortness
+		 (1+ (cdr doctor--repetitive-shortness))))
 	(t
-	 (rplacd repetitive-shortness 1)))
-  (rplaca repetitive-shortness lincount)
-  (cond ((> (cdr repetitive-shortness) 6)
-	 (cond ((not **mad**)
-		(doctor-type '((doc$ areyou)
+	 (rplacd doctor--repetitive-shortness 1)))
+  (rplaca doctor--repetitive-shortness doctor--lincount)
+  (cond ((> (cdr doctor--repetitive-shortness) 6)
+	 (cond ((not doctor--**mad**)
+		(doctor-type '((doc$ doctor--areyou)
 			       just trying to see what kind of things
 			       i have in my vocabulary \? please try to
 			       carry on a reasonable conversation!))
-		(setq **mad** t))
+		(setq doctor--**mad** t))
 	       (t
 		(doctor-type '(i give up \. you need a lesson in creative
 				 writing \.\.\.))
 		)))
 	(t
-	 (cond ((equal sent (doctor-assm '(yes)))
-		(doctor-type '((doc$ isee) (doc$ inter) (doc$ whysay) this is so \?)))
-	       ((equal sent (doctor-assm '(because)))
-		(doctor-type (doc$ shortbeclst)))
-	       ((equal sent (doctor-assm '(no)))
-		(doctor-type (doc$ neglst)))
-	       (t (doctor-type (doc$ shortlst)))))))
+	 (cond ((equal doctor-sent (doctor-assm '(yes)))
+		(doctor-type '((doc$ doctor--isee) (doc$ doctor--inter) (doc$ doctor--whysay) this is so \?)))
+	       ((equal doctor-sent (doctor-assm '(because)))
+		(doctor-type (doc$ doctor--shortbeclst)))
+	       ((equal doctor-sent (doctor-assm '(no)))
+		(doctor-type (doc$ doctor--neglst)))
+	       (t (doctor-type (doc$ doctor--shortlst)))))))
 
-(defun doctor-alcohol () (doctor-type (doc$ drnk)))
+(defun doctor-alcohol () (doctor-type (doc$ doctor--drnk)))
 
 (defun doctor-desire ()
-  (let ((foo (memq found sent)))
+  (let ((foo (memq doctor-found doctor-sent)))
     (cond ((< (length foo) 2)
-	   (doctor-go (doctor-build (doctor-meaning found) 1)))
+	   (doctor-go (doctor-build (doctor-meaning doctor-found) 1)))
 	  ((memq (cadr foo) '(a an))
 	   (rplacd foo (append '(to have) (cdr foo)))
-	   (doctor-svo sent found 1 nil)
-	   (doctor-remember (list subj 'would 'like obj))
-	   (doctor-type (doc$ whywant)))
+	   (doctor-svo doctor-sent doctor-found 1 nil)
+	   (doctor-remember (list doctor-subj 'would 'like doctor-obj))
+	   (doctor-type (doc$ doctor--whywant)))
 	  ((not (eq (cadr foo) 'to))
-	   (doctor-go (doctor-build (doctor-meaning found) 1)))
+	   (doctor-go (doctor-build (doctor-meaning doctor-found) 1)))
 	  (t
-	   (doctor-svo sent found 1 nil)
-	   (doctor-remember (list subj 'would 'like obj))
-	   (doctor-type (doc$ whywant))))))
+	   (doctor-svo doctor-sent doctor-found 1 nil)
+	   (doctor-remember (list doctor-subj 'would 'like doctor-obj))
+	   (doctor-type (doc$ doctor--whywant))))))
 
 (defun doctor-drug ()
-  (doctor-type (doc$ drugs))
-  (doctor-remember (list 'you 'used found)))
+  (doctor-type (doc$ doctor--drugs))
+  (doctor-remember (list 'you 'used doctor-found)))
 
 (defun doctor-toke ()
-  (doctor-type (doc$ toklst)))
+  (doctor-type (doc$ doctor--toklst)))
 
 (defun doctor-state ()
-  (doctor-type (doc$ states))(doctor-remember (list 'you 'were found)))
+  (doctor-type (doc$ doctor--states))(doctor-remember (list 'you 'were doctor-found)))
 
 (defun doctor-mood ()
-  (doctor-type (doc$ moods))(doctor-remember (list 'you 'felt found)))
+  (doctor-type (doc$ doctor--moods))(doctor-remember (list 'you 'felt doctor-found)))
 
 (defun doctor-fear ()
-  (setq feared (doctor-setprep sent found))
-  (doctor-type (doc$ fears))
-  (doctor-remember (list 'you 'were 'afraid 'of feared)))
+  (setq doctor--feared (doctor-setprep doctor-sent doctor-found))
+  (doctor-type (doc$ doctor--fears))
+  (doctor-remember (list 'you 'were 'afraid 'of doctor--feared)))
 
 (defun doctor-hate ()
-  (doctor-svo sent found 1 t)
-  (cond ((memq 'not sent) (doctor-forget) (doctor-huh))
-	((equal subj 'you)
-	 (doctor-type '(why do you (doc// verb)(doc// obj) \?)))
-	(t (doctor-type '((doc$ whysay)(list subj verb obj))))))
+  (doctor-svo doctor-sent doctor-found 1 t)
+  (cond ((memq 'not doctor-sent) (doctor-forget) (doctor-huh))
+	((equal doctor-subj 'you)
+	 (doctor-type '(why do you (doc// doctor-verb)(doc// doctor-obj) \?)))
+	(t (doctor-type '((doc$ doctor--whysay)(list doctor-subj doctor-verb doctor-obj))))))
 
 (defun doctor-symptoms ()
-  (doctor-type '((doc$ maybe) you should consult a medical doctor\;
+  (doctor-type '((doc$ doctor--maybe) you should consult a medical doctor\;
 		 i am a psychotherapist. \.)))
 
 (defun doctor-hates ()
-  (doctor-svo sent found 1 t)
+  (doctor-svo doctor-sent doctor-found 1 t)
   (doctor-hates1))
 
 (defun doctor-hates1 ()
-  (doctor-type '((doc$ whysay)(list subj verb obj) \?)))
+  (doctor-type '((doc$ doctor--whysay)(list doctor-subj doctor-verb doctor-obj) \?)))
 
 (defun doctor-loves ()
-  (doctor-svo sent found 1 t)
+  (doctor-svo doctor-sent doctor-found 1 t)
   (doctor-qloves))
 
 (defun doctor-qloves ()
-  (doctor-type '((doc$ bother)(list subj verb obj) \?)))
+  (doctor-type '((doc$ doctor--bother)(list doctor-subj doctor-verb doctor-obj) \?)))
 
 (defun doctor-love ()
-  (doctor-svo sent found 1 t)
-  (cond ((memq 'not sent) (doctor-forget) (doctor-huh))
-	((memq 'to sent) (doctor-hates1))
+  (doctor-svo doctor-sent doctor-found 1 t)
+  (cond ((memq 'not doctor-sent) (doctor-forget) (doctor-huh))
+	((memq 'to doctor-sent) (doctor-hates1))
 	(t
-	 (cond ((equal object 'something)
-		(setq object '(this person you love))))
-	 (cond ((equal subj 'you)
-		(setq lover obj)
-		(cond ((equal lover '(this person you love))
-		       (setq lover '(your partner))
+	 (cond ((equal doctor-object 'something)
+		(setq doctor-object '(this person you love))))
+	 (cond ((equal doctor-subj 'you)
+		(setq doctor--lover doctor-obj)
+		(cond ((equal doctor--lover '(this person you love))
+		       (setq doctor--lover '(your partner))
 		       (doctor-forget)
 		       (doctor-type '(with whom are you in love \?)))
-		      ((doctor-type '((doc$ please)
-				      (doc$ describe)
-				      (doc$ relation)
-				      (doc// lover)
+		      ((doctor-type '((doc$ doctor--please)
+				      (doc$ doctor--describe)
+				      (doc$ doctor--relation)
+				      (doc// doctor--lover)
 				      \.)))))
-	       ((equal subj 'i)
+	       ((equal doctor-subj 'i)
 		(doctor-txtype '(we were discussing you!)))
 	       (t (doctor-forget)
-		  (setq obj 'someone)
-		  (setq verb (doctor-build verb 's))
+		  (setq doctor-obj 'someone)
+		  (setq doctor-verb (doctor-build doctor-verb 's))
 		  (doctor-qloves))))))
 
 (defun doctor-mach ()
-  (setq found (doctor-plural found))
-  (doctor-type (doc$ machlst)))
+  (setq doctor-found (doctor-plural doctor-found))
+  (doctor-type (doc$ doctor--machlst)))
 
 (defun doctor-sexnoun () (doctor-sexverb))
 
 (defun doctor-sexverb ()
-  (if (or (memq 'me sent)(memq 'myself sent)(memq 'i sent))
+  (if (or (memq 'me doctor-sent)(memq 'myself doctor-sent)(memq 'i doctor-sent))
       (doctor-foul)
-    (doctor-type (doc$ sexlst))))
+    (doctor-type (doc$ doctor--sexlst))))
 
 (defun doctor-death ()
-  (cond (suicide-flag (doctor-type (doc$ deathlst)))
-	((or (equal found 'suicide)
-             (and (or (equal found 'kill)
-                      (equal found 'killing))
-                  (memq 'yourself sent)))
-	 (setq suicide-flag t)
+  (cond (doctor--suicide-flag (doctor-type (doc$ doctor--deathlst)))
+	((or (equal doctor-found 'suicide)
+             (and (or (equal doctor-found 'kill)
+                      (equal doctor-found 'killing))
+                  (memq 'yourself doctor-sent)))
+	 (setq doctor--suicide-flag t)
 	 (doctor-type '(If you are really suicidal, you might
 			   want to contact the Samaritans via
 			   E-mail: jo@samaritans.org or, at your option,
 			   anonymous E-mail: samaritans@anon.twwells.com\ \.
                            or find a Befrienders crisis center at
 			   http://www.befrienders.org/\ \.
-			   (doc$ please) (doc$ continue) \.)))
-	(t (doctor-type (doc$ deathlst)))))
+			   (doc$ doctor--please) (doc$ doctor--continue) \.)))
+	(t (doctor-type (doc$ doctor--deathlst)))))
 
 (defun doctor-foul ()
-  (doctor-type (doc$ foullst)))
+  (doctor-type (doc$ doctor--foullst)))
 
 (defun doctor-family ()
-  (doctor-possess sent found)
-  (doctor-type (doc$ famlst)))
+  (doctor-possess doctor-sent doctor-found)
+  (doctor-type (doc$ doctor--famlst)))
 
 ;; I did not add this -- rms.
 ;; But he might have removed it.  I put it back.  --roland
 (defun doctor-rms ()
-  (cond (rms-flag (doctor-type (doc$ stallmanlst)))
-	(t (setq rms-flag t) (doctor-type '(do you know Stallman \?)))))
+  (cond (doctor--rms-flag (doctor-type (doc$ doctor--stallmanlst)))
+	(t (setq doctor--rms-flag t) (doctor-type '(do you know Stallman \?)))))
 
-(defun doctor-school nil (doctor-type (doc$ schoollst)))
+(defun doctor-school nil (doctor-type (doc$ doctor--schoollst)))
 
 (defun doctor-eliza ()
-  (cond (eliza-flag (doctor-type (doc$ elizalst)))
-	(t (setq eliza-flag t)
-	   (doctor-type '((doc// found) \? hah !
-			  (doc$ please) (doc$ continue) \.)))))
+  (cond (doctor--eliza-flag (doctor-type (doc$ doctor--elizalst)))
+	(t (setq doctor--eliza-flag t)
+	   (doctor-type '((doc// doctor-found) \? hah !
+			  (doc$ doctor--please) (doc$ doctor--continue) \.)))))
 
-(defun doctor-sports ()  (doctor-type (doc$ sportslst)))
+(defun doctor-sports () (doctor-type (doc$ doctor--sportslst)))
 
-(defun doctor-math () (doctor-type (doc$ mathlst)))
+(defun doctor-math () (doctor-type (doc$ doctor--mathlst)))
 
 (defun doctor-zippy ()
-  (cond (zippy-flag (doctor-type (doc$ zippylst)))
-	(t (setq zippy-flag t)
+  (cond (doctor--zippy-flag (doctor-type (doc$ doctor--zippylst)))
+	(t (setq doctor--zippy-flag t)
 	   (doctor-type '(yow! are we interactive yet \?)))))
 
 
-(defun doctor-chat () (doctor-type (doc$ chatlst)))
+(defun doctor-chat () (doctor-type (doc$ doctor--chatlst)))
 
 (random t)
 
 (provide 'doctor)
 
-;; arch-tag: 579380f6-4902-4ea5-bccb-6339e30e1257
 ;;; doctor.el ends here
--- a/lisp/play/fortune.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/play/fortune.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,7 @@
 ;;; fortune.el --- use fortune to create signatures
 
-;; Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-;;  2008, 2009, 2010  Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+;;  2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: Holger Schauer <Holger.Schauer@gmx.de>
 ;; Keywords: games utils mail
@@ -285,48 +285,41 @@
 ;;; Display fortune
 (defun fortune-in-buffer (interactive &optional file)
   "Put a fortune cookie in the *fortune* buffer.
-
-INTERACTIVE is ignored.  Optional argument FILE,
-when supplied, specifies the file to choose the fortune from."
+INTERACTIVE is ignored.  Optional argument FILE, when supplied,
+specifies the file to choose the fortune from."
   (let ((fortune-buffer (or (get-buffer fortune-buffer-name)
 			    (generate-new-buffer fortune-buffer-name)))
 	(fort-file (expand-file-name
 		    (substitute-in-file-name
 		     (or file fortune-file)))))
     (with-current-buffer fortune-buffer
-      (toggle-read-only 0)
-      (erase-buffer)
-
-      (if fortune-always-compile
-	  (fortune-compile fort-file))
-
-      (apply 'call-process
-             fortune-program            ; program to call
-             nil fortune-buffer nil     ; INFILE BUFFER DISPLAY
-             (append (if (stringp fortune-program-options)
-                         (split-string fortune-program-options)
-                       fortune-program-options) (list fort-file))))))
+      (let ((inhibit-read-only t))
+        (erase-buffer)
+        (if fortune-always-compile
+            (fortune-compile fort-file))
+        (apply 'call-process
+               fortune-program            ; program to call
+               nil fortune-buffer nil     ; INFILE BUFFER DISPLAY
+               (append (if (stringp fortune-program-options)
+                           (split-string fortune-program-options)
+                         fortune-program-options) (list fort-file)))))))
 
 ;;;###autoload
 (defun fortune (&optional file)
   "Display a fortune cookie.
-
 If called with a prefix asks for the FILE to choose the fortune from,
 otherwise uses the value of `fortune-file'.  If you want to have fortune
 choose from a set of files in a directory, call interactively with prefix
 and choose the directory as the fortune-file."
-  (interactive
-    (list
-     (if current-prefix-arg
-	 (fortune-ask-file)
-       fortune-file)))
+  (interactive (list (if current-prefix-arg
+                         (fortune-ask-file)
+                       fortune-file)))
   (fortune-in-buffer t file)
   (switch-to-buffer (get-buffer fortune-buffer-name))
-  (toggle-read-only 1))
+  (setq buffer-read-only t))
 
 
 ;;; Provide ourselves.
 (provide 'fortune)
 
-;; arch-tag: a1e4cb8a-3792-40e7-86a7-fc75ce094bcc
 ;;; fortune.el ends here
--- a/lisp/play/gametree.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/play/gametree.el	Mon Nov 08 14:19:54 2010 +0900
@@ -201,7 +201,7 @@
     (let ((boundary (concat "[ \t]*\\([1-9][0-9]*\\)\\("
                             gametree-full-ply-regexp "\\|"
                             gametree-half-ply-regexp "\\)"))
-          (limit (save-excursion (beginning-of-line 1) (point))))
+          (limit (line-beginning-position 1)))
       (if (looking-at boundary)
           (+ (* 2 (string-to-number (match-string 1)))
              (if (string-match gametree-half-ply-regexp (match-string 2)) 1 0))
@@ -617,5 +617,4 @@
 
 (provide 'gametree)
 
-;; arch-tag: aaa30943-9ae4-4cc1-813d-a46f96b7e4f1
 ;;; gametree.el ends here
--- a/lisp/play/gomoku.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/play/gomoku.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,7 @@
 ;;; gomoku.el --- Gomoku game between you and Emacs
 
-;; Copyright (C) 1988, 1994, 1996, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1988, 1994, 1996, 2001, 2002, 2003, 2004, 2005, 2006,
+;;   2007, 2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: Philippe Schnoebelen <phs@lsv.ens-cachan.fr>
 ;; Maintainer: FSF
@@ -195,8 +195,8 @@
 \\{gomoku-mode-map}"
   (gomoku-display-statistics)
   (make-local-variable 'font-lock-defaults)
-  (setq font-lock-defaults '(gomoku-font-lock-keywords t))
-  (toggle-read-only t))
+  (setq font-lock-defaults '(gomoku-font-lock-keywords t)
+	buffer-read-only t))
 
 ;;;
 ;;; THE BOARD.
@@ -278,7 +278,7 @@
 ;; its contents as a set, i.e. not considering the order of its elements. The
 ;; highest score is given to the "OOOO" qtuples because playing in such a
 ;; qtuple is winning the game. Just after this comes the "XXXX" qtuple because
-;; not playing in it is just loosing the game, and so on. Note that a
+;; not playing in it is just losing the game, and so on. Note that a
 ;; "polluted" qtuple, i.e. one containing at least one X and at least one O,
 ;; has score zero because there is no more any point in playing in it, from
 ;; both an attacking and a defending point of view.
@@ -299,15 +299,15 @@
 ;; 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 gomoku-nil-score	  7  "Score of an empty qtuple.")
+(defconst gomoku-Xscore	 15  "Score of a qtuple containing one X.")
+(defconst gomoku-XXscore	400  "Score of a qtuple containing two X's.")
+(defconst gomoku-XXXscore     1800  "Score of a qtuple containing three X's.")
+(defconst gomoku-XXXXscore  100000  "Score of a qtuple containing four X's.")
+(defconst gomoku-Oscore	 35  "Score of a qtuple containing one O.")
+(defconst gomoku-OOscore	800  "Score of a qtuple containing two O's.")
+(defconst gomoku-OOOscore    15000  "Score of a qtuple containing three O's.")
+(defconst gomoku-OOOOscore  800000  "Score of a qtuple containing four O's.")
 
 ;; These values are not just random: if, given the following situation:
 ;;
@@ -320,7 +320,7 @@
 ;; you want Emacs to play in "a" and not in "b", then the parameters must
 ;; satisfy the inequality:
 ;;
-;;		   6 * XXscore > XXXscore + XXscore
+;;		   6 * gomoku-XXscore > gomoku-XXXscore + gomoku-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
@@ -334,26 +334,26 @@
 ;; we just have to set up a translation table.
 
 (defconst gomoku-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
+  (vector gomoku-nil-score gomoku-Xscore gomoku-XXscore gomoku-XXXscore gomoku-XXXXscore 0
+	  gomoku-Oscore    0	   0	   0	    0	      0
+	  gomoku-OOscore   0	   0	   0	    0	      0
+	  gomoku-OOOscore  0	   0	   0	    0	      0
+	  gomoku-OOOOscore 0	   0	   0	    0	      0
 	  0)
   "Vector associating qtuple contents to their score.")
 
 
 ;; If you do not modify drastically the previous constants, the only way for a
-;; square to have a score higher than OOOOscore is to belong to a "OOOO"
+;; square to have a score higher than gomoku-OOOOscore is to belong to a "OOOO"
 ;; qtuple, thus to be a winning move. Similarly, the only way for a square to
-;; have a score between XXXXscore and OOOOscore is to belong to a "XXXX"
+;; have a score between gomoku-XXXXscore and gomoku-OOOOscore is to belong to a "XXXX"
 ;; qtuple. We may use these considerations to detect when a given move is
-;; winning or loosing.
+;; winning or losing.
 
-(defconst gomoku-winning-threshold OOOOscore
+(defconst gomoku-winning-threshold gomoku-OOOOscore
   "Threshold score beyond which an Emacs move is winning.")
 
-(defconst gomoku-loosing-threshold XXXXscore
+(defconst gomoku-losing-threshold gomoku-XXXXscore
   "Threshold score beyond which a human move is winning.")
 
 
@@ -394,10 +394,10 @@
 ;;;
 
 ;; At initialization the board is empty so that every qtuple amounts for
-;; nil-score. Therefore, the score of any square is nil-score times the number
+;; gomoku-nil-score. Therefore, the score of any square is gomoku-nil-score times the number
 ;; of qtuples that pass through it. This number is 3 in a corner and 20 if you
 ;; are sufficiently far from the sides. As computing the number is time
-;; consuming, we initialize every square with 20*nil-score and then only
+;; consuming, we initialize every square with 20*gomoku-nil-score and then only
 ;; consider squares at less than 5 squares from one side. We speed this up by
 ;; taking symmetry into account.
 ;; Also, as it is likely that successive games will be played on a board with
@@ -421,7 +421,7 @@
       (setq gomoku-score-table (copy-sequence gomoku-saved-score-table))
       ;; No, compute it:
       (setq gomoku-score-table
-	    (make-vector gomoku-vector-length (* 20 nil-score)))
+	    (make-vector gomoku-vector-length (* 20 gomoku-nil-score)))
       (let (i j maxi maxj maxi2 maxj2)
 	(setq maxi  (/ (1+ gomoku-board-width) 2)
 	      maxj  (/ (1+ gomoku-board-height) 2)
@@ -872,7 +872,7 @@
 	    (t
 	     (setq score (aref gomoku-score-table square))
 	     (gomoku-play-move square 1)
-	     (cond ((and (>= score gomoku-loosing-threshold)
+	     (cond ((and (>= score gomoku-losing-threshold)
 			 ;; Just testing SCORE > THRESHOLD is not enough for
 			 ;; detecting wins, it just gives an indication that
 			 ;; we confirm with GOMOKU-FIND-FILLED-QTUPLE.
@@ -1206,5 +1206,4 @@
 
 (provide 'gomoku)
 
-;; arch-tag: b1b8205e-77fc-4597-b373-3ea2c04311eb
 ;;; gomoku.el ends here
--- a/lisp/play/landmark.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/play/landmark.el	Mon Nov 08 14:19:54 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))
@@ -255,8 +255,8 @@
   (lm-display-statistics)
   (use-local-map lm-mode-map)
   (make-local-variable 'font-lock-defaults)
-  (setq font-lock-defaults '(lm-font-lock-keywords t))
-  (toggle-read-only t)
+  (setq font-lock-defaults '(lm-font-lock-keywords t)
+	buffer-read-only t)
   (run-mode-hooks 'lm-mode-hook))
 
 
@@ -282,7 +282,7 @@
 ;; its contents as a set, i.e. not considering the order of its elements. The
 ;; highest score is given to the "OOOO" qtuples because playing in such a
 ;; qtuple is winning the game. Just after this comes the "XXXX" qtuple because
-;; not playing in it is just loosing the game, and so on. Note that a
+;; not playing in it is just losing the game, and so on. Note that a
 ;; "polluted" qtuple, i.e. one containing at least one X and at least one O,
 ;; has score zero because there is no more any point in playing in it, from
 ;; both an attacking and a defending point of view.
@@ -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.")
 
 
@@ -352,12 +352,14 @@
 ;; qtuple, thus to be a winning move. Similarly, the only way for a square to
 ;; have a score between XXXXscore and OOOOscore is to belong to a "XXXX"
 ;; qtuple. We may use these considerations to detect when a given move is
-;; winning or loosing.
+;; winning or losing.
 
-(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-losing-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)
@@ -769,7 +771,7 @@
 	    (t
 	     (setq score (aref lm-score-table square))
 	     (lm-play-move square 1)
-	     (cond ((and (>= score lm-loosing-threshold)
+	     (cond ((and (>= score lm-losing-threshold)
 			 ;; Just testing SCORE > THRESHOLD is not enough for
 			 ;; detecting wins, it just gives an indication that
 			 ;; we confirm with LM-FIND-FILLED-QTUPLE.
@@ -1700,5 +1702,4 @@
 
 (provide 'landmark)
 
-;; arch-tag: ae5031be-96e6-459e-a3df-1df53117d3f2
 ;;; landmark.el ends here
--- a/lisp/play/life.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/play/life.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,7 @@
 ;;; life.el --- John Horton Conway's `Life' game for GNU Emacs
 
-;; Copyright (C) 1988, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1988, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+;;   2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: Kyle Jones <kyleuunet.uu.net>
 ;; Maintainer: FSF
@@ -163,7 +163,7 @@
       (replace-match (life-life-string) t t))
     ;; center the pattern horizontally
     (goto-char (point-min))
-    (setq n (/ (- fill-column (save-excursion (end-of-line) (point))) 2))
+    (setq n (/ (- fill-column (line-end-position)) 2))
     (while (not (eobp))
       (indent-to n)
       (forward-line))
@@ -302,5 +302,4 @@
 
 (provide 'life)
 
-;; arch-tag: e9373544-755e-42f5-a9a1-4d4c422bb97a
 ;;; life.el ends here
--- a/lisp/progmodes/ada-mode.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/progmodes/ada-mode.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,8 @@
 ;;; ada-mode.el --- major-mode for editing Ada sources
 
-;; Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
+;; Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
+;;   2004, 2005, 2006, 2007, 2008, 2009, 2010
+;;   Free Software Foundation, Inc.
 
 ;; Author: Rolf Ebert      <ebert@inf.enst.fr>
 ;;      Markus Heritsch <Markus.Heritsch@studbox.uni-stuttgart.de>
@@ -1117,9 +1118,9 @@
 	(funcall (symbol-function 'speedbar-add-supported-extension)
 		 spec)
 	(funcall (symbol-function 'speedbar-add-supported-extension)
-		 body)))
-  )
-
+		 body))))
+
+(defvar ada-font-lock-syntactic-keywords) ; defined below
 
 ;;;###autoload
 (defun ada-mode ()
@@ -2601,7 +2602,7 @@
      ((and (= (char-after) ?#)
 	   (equal ada-which-compiler 'gnat)
 	   (looking-at "#[ \t]*\\(if\\|els\\(e\\|if\\)\\|end[ \t]*if\\)"))
-      (list (save-excursion (beginning-of-line) (point)) 0))
+      (list (point-at-bol) 0))
 
      ;;--------------------------------
      ;;   starting with ')' (end of a parameter list)
@@ -4048,11 +4049,7 @@
                   (funcall search-func search-re limit 1))
         (setq begin (match-beginning 0))
         (setq end (match-end 0))
-
-        (setq parse-result (parse-partial-sexp
-                            (save-excursion (beginning-of-line) (point))
-                            (point)))
-
+        (setq parse-result (parse-partial-sexp (point-at-bol) (point)))
         (cond
          ;;
          ;; If inside a string, skip it (and the following comments)
@@ -4271,16 +4268,12 @@
   (save-excursion
     (beginning-of-line)
     (insert-char ?  ada-indent))
-  (if (save-excursion (= (point) (progn (beginning-of-line) (point))))
-      (forward-char ada-indent)))
+  (if (bolp) (forward-char ada-indent)))
 
 (defun ada-untab-hard ()
   "Indent current line to previous tab stop."
   (interactive)
-  (let ((bol (save-excursion (progn (beginning-of-line) (point))))
-	(eol (save-excursion (progn (end-of-line) (point)))))
-    (indent-rigidly bol eol (- 0 ada-indent))))
-
+  (indent-rigidly (point-at-bol) (point-at-eol) (- 0 ada-indent)))
 
 
 ;; ------------------------------------------------------------
@@ -5538,5 +5531,4 @@
 ;;; provide ourselves
 (provide 'ada-mode)
 
-;; arch-tag: 1b7d45ec-1698-43b5-8d4a-e479ea023270
 ;;; ada-mode.el ends here
--- a/lisp/progmodes/ada-prj.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/progmodes/ada-prj.el	Mon Nov 08 14:19:54 2010 +0900
@@ -196,21 +196,17 @@
       (widen)
       (goto-char (point-min))
       (while (not (eobp))
-	(set 'line (buffer-substring-no-properties
-		    (point) (save-excursion (end-of-line) (point))))
+	(set 'line (buffer-substring-no-properties (point) (point-at-eol)))
 	(add-to-list 'list line)
-	(forward-line 1)
-	)
+	(forward-line 1))
       (kill-buffer nil)
       (set-buffer buffer)
       (set 'ada-prj-current-values
 	   (plist-put ada-prj-current-values
 		      symbol
 		      (append (plist-get ada-prj-current-values symbol)
-			      (reverse list))))
-      )
-    (ada-prj-display-page 2)
-  ))
+			      (reverse list)))))
+    (ada-prj-display-page 2)))
 
 (defun ada-prj-subdirs-of (dir)
   "Return a list of all the subdirectories of DIR, recursively."
@@ -568,8 +564,7 @@
       ;;  variables
       (momentary-string-display
        (concat "*****Help*****\n" text "\n**************\n")
-       (save-excursion (forward-line) (beginning-of-line) (point)))
-      )))
+       (point-at-bol 2)))))
 
 (defun ada-prj-show-value (widget widget-modified event)
   "Show the current field value in WIDGET.
@@ -681,5 +676,4 @@
 
 (provide 'ada-prj)
 
-;; arch-tag: 65978c77-816e-49c6-896e-6905605d1b4c
 ;;; ada-prj.el ends here
--- a/lisp/progmodes/ada-xref.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/progmodes/ada-xref.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,8 @@
 ;; ada-xref.el --- for lookup and completion in Ada mode
 
-;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-;;   2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+;;   2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+;;   Free Software Foundation, Inc.
 
 ;; Author: Markus Heritsch <Markus.Heritsch@studbox.uni-stuttgart.de>
 ;;      Rolf Ebert <ebert@inf.enst.fr>
@@ -324,7 +325,7 @@
 		    (add-to-list 'ada-xref-runtime-library-specs-path
 				 (buffer-substring-no-properties
 				  (point)
-				  (save-excursion (end-of-line) (point)))))
+				  (point-at-eol))))
 		  (forward-line 1))
 
 		;;  Object path
@@ -338,7 +339,7 @@
 		    (add-to-list 'ada-xref-runtime-library-ali-path
 				 (buffer-substring-no-properties
 				  (point)
-				  (save-excursion (end-of-line) (point)))))
+				  (point-at-eol))))
 		  (forward-line 1))
 		)
 	    (kill-buffer nil))))
@@ -1817,7 +1818,7 @@
     (beginning-of-line)
     (if declaration-found
 	(let ((current-line (buffer-substring
-			     (point) (save-excursion (end-of-line) (point)))))
+			     (point) (point-at-eol))))
 	  (save-excursion
 	    (forward-line 1)
 	    (beginning-of-line)
@@ -2379,5 +2380,4 @@
 
 (provide 'ada-xref)
 
-;; arch-tag: 415a39fe-577b-4676-b3b1-6ff6db7ca24e
 ;;; ada-xref.el ends here
--- a/lisp/progmodes/cc-cmds.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/progmodes/cc-cmds.el	Mon Nov 08 14:19:54 2010 +0900
@@ -3974,17 +3974,19 @@
 		    ;; "Invalid search bound (wrong side of point)"
 		    ;; error in the subsequent re-search.  Maybe
 		    ;; another fix would be needed (2007-12-08).
-		    (or (<= (- (cdr c-lit-limits) 2) (point))
-			(and 
-			 (search-forward-regexp
-			  (concat "\\=[ \t]*\\(" c-current-comment-prefix "\\)")
-			  (- (cdr c-lit-limits) 2) t)
-			 (not (search-forward-regexp
-			       "\\(\\s \\|\\sw\\)"
-			       (- (cdr c-lit-limits) 2) 'limit))
-			 ;; The comment ender IS on its own line.  Exclude
-			 ;; this line from the filling.
-			 (set-marker end (c-point 'bol)))))
+;		    (or (<= (- (cdr c-lit-limits) 2) (point))
+; 2010-10-17  Construct removed.
+;		    (or (< (- (cdr c-lit-limits) 2) (point))
+		    (and 
+		     (search-forward-regexp
+		      (concat "\\=[ \t]*\\(" c-current-comment-prefix "\\)")
+		      (- (cdr c-lit-limits) 2) t)
+		     (not (search-forward-regexp
+			   "\\(\\s \\|\\sw\\)"
+			   (- (cdr c-lit-limits) 2) 'limit))
+		     ;; The comment ender IS on its own line.  Exclude this
+		     ;; line from the filling.
+		     (set-marker end (c-point 'bol))));)
 
 		;; The comment ender is hanging.  Replace all space between it
 		;; and the last word either by one or two 'x's (when
--- a/lisp/progmodes/cc-fonts.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/progmodes/cc-fonts.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1045,6 +1045,12 @@
 	  ;; 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
+	  ;; 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 +1190,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 "{"?
@@ -1306,6 +1321,40 @@
 
       nil)))
 
+(defun c-font-lock-enum-tail (limit)
+  ;; Fontify an enum's identifiers when POINT is within the enum's brace
+  ;; block.
+  ;;
+  ;; This function will be called from font-lock for a region bounded by POINT
+  ;; and LIMIT, as though it were to identify a keyword for
+  ;; font-lock-keyword-face.  It always returns NIL to inhibit this and
+  ;; prevent a repeat invocation.  See elisp/lispref page "Search-based
+  ;; Fontification".
+  ;;
+  ;; Note that this function won't attempt to fontify beyond the end of the
+  ;; current enum block, if any.
+  (let* ((paren-state (c-parse-state))
+	 (encl-pos (c-most-enclosing-brace paren-state))
+	 (start (point))
+	)
+    (when (and
+	   encl-pos
+	   (eq (char-after encl-pos) ?\{)
+	   (save-excursion
+	     (goto-char encl-pos)
+	     (c-backward-syntactic-ws)
+	     (c-simple-skip-symbol-backward)
+	     (or (looking-at c-brace-list-key) ; "enum"
+		 (progn (c-backward-syntactic-ws)
+			(c-simple-skip-symbol-backward)
+			(looking-at c-brace-list-key)))))
+      (c-syntactic-skip-backward "^{," nil t)
+      (c-put-char-property (1- (point)) 'c-type 'c-decl-id-start)
+
+      (c-forward-syntactic-ws)
+      (c-font-lock-declarators limit t nil)))
+  nil)
+
 (c-lang-defconst c-simple-decl-matchers
   "Simple font lock matchers for types and declarations.  These are used
 on level 2 only and so aren't combined with `c-complex-decl-matchers'."
@@ -1570,11 +1619,14 @@
 generic casts and declarations are fontified.  Used on level 2 and
 higher."
 
-  t `(;; Fontify the identifiers inside enum lists.  (The enum type
+  t `(,@(when (c-lang-const c-brace-id-list-kwds)
+      ;; Fontify the remaining identifiers inside an enum list when we start
+      ;; inside it.
+	  `(c-font-lock-enum-tail
+      ;; Fontify the identifiers inside enum lists.  (The enum type
       ;; name is handled by `c-simple-decl-matchers' or
       ;; `c-complex-decl-matchers' below.
-      ,@(when (c-lang-const c-brace-id-list-kwds)
-	  `((,(c-make-font-lock-search-function
+	    (,(c-make-font-lock-search-function
 	       (concat
 		"\\<\\("
 		(c-make-keywords-re nil (c-lang-const c-brace-id-list-kwds))
--- a/lisp/progmodes/cc-langs.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/progmodes/cc-langs.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/progmodes/cc-mode.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/progmodes/compile.el	Mon Nov 08 14:19:54 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/cperl-mode.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/progmodes/cperl-mode.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,8 +1,8 @@
 ;;; cperl-mode.el --- Perl code editing commands for Emacs
 
-;; Copyright (C) 1985, 1986, 1987, 1991, 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) 1985, 1986, 1987, 1991, 1992, 1993, 1994, 1995, 1996,
+;;   1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+;;   2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: Ilya Zakharevich
 ;;	Bob Olson
@@ -2145,7 +2145,7 @@
   "Insert an opening parenthesis or a matching pair of parentheses.
 See `cperl-electric-parens'."
   (interactive "P")
-  (let ((beg (save-excursion (beginning-of-line) (point)))
+  (let ((beg (point-at-bol))
 	(other-end (if (and cperl-electric-parens-mark
 			    (cperl-mark-active)
 			    (> (mark) (point)))
@@ -2182,7 +2182,7 @@
 If not, or if we are not at the end of marking range, would self-insert.
 Affected by `cperl-electric-parens'."
   (interactive "P")
-  (let ((beg (save-excursion (beginning-of-line) (point)))
+  (let ((beg (point-at-bol))
 	(other-end (if (and cperl-electric-parens-mark
 			    (cperl-val 'cperl-electric-parens)
 			    (memq last-command-event
@@ -2215,7 +2215,7 @@
   "Insert a construction appropriate after a keyword.
 Help message may be switched off by setting `cperl-message-electric-keyword'
 to nil."
-  (let ((beg (save-excursion (beginning-of-line) (point)))
+  (let ((beg (point-at-bol))
 	(dollar (and (eq last-command-event ?$)
 		     (eq this-command 'self-insert-command)))
 	(delete (and (memq last-command-event '(?\s ?\n ?\t ?\f))
@@ -2358,7 +2358,7 @@
   "Insert a construction appropriate after a keyword.
 Help message may be switched off by setting `cperl-message-electric-keyword'
 to nil."
-  (let ((beg (save-excursion (beginning-of-line) (point))))
+  (let ((beg (point-at-bol)))
     (and (save-excursion
 	   (backward-sexp 1)
 	   (cperl-after-expr-p nil "{;:"))
@@ -2397,8 +2397,8 @@
   "Go to end of line, open a new line and indent appropriately.
 If in POD, insert appropriate lines."
   (interactive)
-  (let ((beg (save-excursion (beginning-of-line) (point)))
-	(end (save-excursion (end-of-line) (point)))
+  (let ((beg (point-at-bol))
+	(end (point-at-eol))
 	(pos (point)) start over cut res)
     (if (and				; Check if we need to split:
 					; i.e., on a boundary and inside "{...}"
@@ -2476,12 +2476,8 @@
 		   (forward-paragraph -1)
 		   (forward-word 1)
 		   (setq pos (point))
-		   (setq cut (buffer-substring (point)
-					       (save-excursion
-						 (end-of-line)
-						 (point))))
-		   (delete-char (- (save-excursion (end-of-line) (point))
-				   (point)))
+		   (setq cut (buffer-substring (point) (point-at-eol)))
+		   (delete-char (- (point-at-eol) (point)))
 		   (setq res (expand-abbrev))
 		   (save-excursion
 		     (goto-char pos)
@@ -2946,8 +2942,7 @@
 					(point-max)))) ; do not loop if no syntaxification
 				  ;; label:
 				  (t
-				   (save-excursion (end-of-line)
-						   (setq colon-line-end (point)))
+				   (setq colon-line-end (point-at-eol))
 				   (search-forward ":"))))
 			  ;; We are at beginning of code (NOT label or comment)
 			  ;; First, the following code counts
@@ -3220,7 +3215,7 @@
 Returns true if comment is found.  In POD will not move the point."
   ;; If the line is inside other syntax groups (qq-style strings, HERE-docs)
   ;; then looks for literal # or end-of-line.
-  (let (state stop-in cpoint (lim (progn (end-of-line) (point))) pr e)
+  (let (state stop-in cpoint (lim (point-at-eol)) pr e)
     (or cperl-font-locking
 	(cperl-update-syntaxification lim lim))
     (beginning-of-line)
@@ -3814,7 +3809,7 @@
 		 (let ((case-fold-search t))
 		   (looking-at "extproc[ \t]")) ; Analogue of #!
 		 (cperl-commentify min
-				   (save-excursion (end-of-line) (point))
+				   (point-at-eol)
 				   nil))
 	    (while (and
 		    (< (point) max)
@@ -5002,7 +4997,7 @@
 conditional/loop constructs."
   (interactive)
   (save-excursion
-    (let ((tmp-end (progn (end-of-line) (point))) top done)
+    (let ((tmp-end (point-at-eol)) top done)
       (save-excursion
 	(beginning-of-line)
 	(while (null done)
@@ -5045,13 +5040,9 @@
 			   "\\<\\(else\\|elsif\|continue\\)\\>"))
 		  (progn
 		    (goto-char (match-end 0))
-		    (save-excursion
-		      (end-of-line)
-		      (setq tmp-end (point))))
+		    (setq tmp-end (point-at-eol)))
 		(setq done t))))
-	  (save-excursion
-	    (end-of-line)
-	    (setq tmp-end (point))))
+	  (setq tmp-end (point-at-eol)))
 	(goto-char tmp-end)
 	(setq tmp-end (point-marker)))
       (if cperl-indent-region-fix-constructs
@@ -5064,7 +5055,7 @@
   (interactive)
   (or end
       (setq end (point-max)))
-  (let ((ee (save-excursion (end-of-line) (point)))
+  (let ((ee (point-at-eol))
 	(cperl-indent-region-fix-constructs
 	 (or cperl-indent-region-fix-constructs 1))
 	p pp ml have-brace ret)
@@ -5217,7 +5208,7 @@
 				(if (cperl-indent-line parse-data)
 				    (setq ret (cperl-fix-line-spacing end parse-data)))))))))))
 	(beginning-of-line)
-	(setq p (point) pp (save-excursion (end-of-line) (point))) ; May be different from ee.
+	(setq p (point) pp (point-at-eol)) ; May be different from ee.
 	;; Now check whether there is a hanging `}'
 	;; Looking at:
 	;; } blah
@@ -7479,7 +7470,7 @@
   ;; Get to the something meaningful
   (or (eobp) (eolp) (forward-char 1))
   (re-search-backward "[-a-zA-Z0-9_:!&*+,-./<=>?\\\\^|~$%@]"
-		      (save-excursion (beginning-of-line) (point))
+		      (point-at-bol)
 		      'to-beg)
   ;;  (cond
   ;;   ((or (eobp) (looking-at "[][ \t\n{}();,]")) ; Not at a symbol
@@ -8999,5 +8990,4 @@
 
 (provide 'cperl-mode)
 
-;; arch-tag: 42e5b19b-e187-4537-929f-1a7408980ce6
 ;;; cperl-mode.el ends here
--- a/lisp/progmodes/dcl-mode.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/progmodes/dcl-mode.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,7 @@
 ;;; dcl-mode.el --- major mode for editing DCL command files
 
-;; Copyright (C) 1997, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-;; Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+;;   2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: Odd Gripenstam <gripenstamol@decus.se>
 ;; Maintainer: Odd Gripenstam <gripenstamol@decus.se>
@@ -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)
@@ -821,7 +821,7 @@
   ;;  text
   ;;  1
 
-  (let* ((default-limit (save-excursion (end-of-line) (1+ (point))))
+  (let* ((default-limit (1+ (line-end-position)))
 	 (limit (or limit default-limit))
 	 (last-good-point (point))
 	 (opoint (point)))
@@ -1783,7 +1783,7 @@
 	  (skip-chars-forward " \t")
 	  (or (eolp)
 	      (setq suffix-string (buffer-substring (point)
-					     (progn (end-of-line) (point)))))
+                                                    (line-end-position))))
 	  (goto-char (match-beginning 0))
 	  (or (bolp)
 	      (setq prefix-string
@@ -2214,5 +2214,4 @@
 
 (run-hooks 'dcl-mode-load-hook)		; for your customizations
 
-;; arch-tag: e00d421b-f26c-483e-a8bd-af412ea7764a
 ;;; dcl-mode.el ends here
--- a/lisp/progmodes/ebnf2ps.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/progmodes/ebnf2ps.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,7 @@
 ;;; ebnf2ps.el --- translate an EBNF to a syntactic chart on PostScript
 
-;; 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: Vinicius Jose Latorre <viniciusjl@ig.com.br>
 ;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
@@ -5279,7 +5279,7 @@
     (goto-char (point-min))
     (and (search-forward "%%Creator: " nil t)
 	 (not (search-forward "& ebnf2ps v"
-			      (save-excursion (end-of-line) (point))
+			      (line-end-position)
 			      t))
 	 (progn
 	   ;; adjust creator comment
@@ -6395,5 +6395,4 @@
 
 (provide 'ebnf2ps)
 
-;; arch-tag: 148bc8af-5398-468b-b922-eeb7afef3e4f
 ;;; ebnf2ps.el ends here
--- a/lisp/progmodes/ebrowse.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/progmodes/ebrowse.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,8 +1,8 @@
 ;;; ebrowse.el --- Emacs C++ class browser & tags facility
 
-;; Copyright (C) 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) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+;;   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+;;   Free Software Foundation Inc.
 
 ;; Author: Gerd Moellmann <gerd@gnu.org>
 ;; Maintainer: FSF
@@ -1313,7 +1313,7 @@
 	  (skip-chars-forward " \t*a-zA-Z0-9_")
 	  (setq start (point)
 		file-name-existing (looking-at "("))
-	  (delete-region start (save-excursion (end-of-line) (point)))
+	  (delete-region start (line-end-position))
 	  (unless file-name-existing
 	    (indent-to ebrowse-source-file-column)
 	    (insert "(" (or (ebrowse-cs-file
@@ -4491,5 +4491,4 @@
 ;; eval:(put 'ebrowse-for-all-trees 'lisp-indent-hook 1)
 ;; End:
 
-;; arch-tag: 4fa3c8bf-1771-479b-bcd7-b029c7c9677b
 ;;; ebrowse.el ends here
--- a/lisp/progmodes/etags.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/progmodes/etags.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,8 +1,8 @@
 ;;; etags.el --- etags facility for Emacs
 
-;; Copyright (C) 1985, 1986, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1998,
-;;   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-;;   Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1986, 1988, 1989, 1992, 1993, 1994, 1995, 1996,
+;;   1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
+;;   2010  Free Software Foundation, Inc.
 
 ;; Author: Roland McGrath <roland@gnu.org>
 ;; Maintainer: FSF
@@ -1681,7 +1681,7 @@
   (save-excursion
     (beginning-of-line)
     (let ((bol (point)))
-      (and (search-forward "\177" (save-excursion (end-of-line) (point)) t)
+      (and (search-forward "\177" (line-end-position) t)
 	   (re-search-backward re bol t)))))
 
 (defcustom tags-loop-revert-buffers nil
@@ -2086,5 +2086,4 @@
 
 (provide 'etags)
 
-;; arch-tag: b897c2b5-08f3-4837-b2d3-0e7d6db1b63e
 ;;; etags.el ends here
--- a/lisp/progmodes/f90.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/progmodes/f90.el	Mon Nov 08 14:19:54 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/flymake.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/progmodes/flymake.el	Mon Nov 08 14:19:54 2010 +0900
@@ -106,16 +106,6 @@
       'temp-directory
     (lambda () temporary-file-directory)))
 
-(defalias 'flymake-line-beginning-position
-  (if (fboundp 'line-beginning-position)
-      'line-beginning-position
-    (lambda (&optional arg) (save-excursion (beginning-of-line arg) (point)))))
-
-(defalias 'flymake-line-end-position
-  (if (fboundp 'line-end-position)
-      'line-end-position
-    (lambda (&optional arg) (save-excursion (end-of-line arg) (point)))))
-
 (defun flymake-posn-at-point-as-event (&optional position window dx dy)
   "Return pixel position of top left corner of glyph at POSITION,
 relative to top left corner of WINDOW, as a mouse-1 click
@@ -808,8 +798,8 @@
 Perhaps use text from LINE-ERR-INFO-LIST to enhance highlighting."
   (goto-char (point-min))
   (forward-line (1- line-no))
-  (let* ((line-beg (flymake-line-beginning-position))
-	 (line-end (flymake-line-end-position))
+  (let* ((line-beg (point-at-bol))
+	 (line-end (point-at-eol))
 	 (beg      line-beg)
 	 (end      line-end)
 	 (tooltip-text (flymake-ler-text (nth 0 line-err-info-list)))
@@ -1764,5 +1754,4 @@
 
 (provide 'flymake)
 
-;; arch-tag: 8f0d6090-061d-4cac-8862-7c151c4a02dd
 ;;; flymake.el ends here
--- a/lisp/progmodes/hideif.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/progmodes/hideif.el	Mon Nov 08 14:19:54 2010 +0900
@@ -760,7 +760,7 @@
       (cond ((hif-looking-at-else)
 	     (setq else (point)))
 	    (t
-	     (setq end (point)))) ; (save-excursion (end-of-line) (point))
+	     (setq end (point)))) ; (line-end-position)
       ;; If found #else, look for #endif.
       (when else
 	(while (progn
@@ -769,7 +769,7 @@
 	  (hif-ifdef-to-endif))
 	(if (hif-looking-at-else)
 	    (error "Found two elses in a row?  Broken!"))
-	(setq end (point)))	       ; (save-excursion (end-of-line) (point))
+	(setq end (point)))	       ; (line-end-position)
       (hif-make-range start end else))))
 
 
@@ -1025,5 +1025,4 @@
 
 (provide 'hideif)
 
-;; arch-tag: c6381d17-a59a-483a-b945-658f22277981
 ;;; hideif.el ends here
--- a/lisp/progmodes/icon.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/progmodes/icon.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,7 @@
 ;;; icon.el --- mode for editing Icon code
 
-;; Copyright (C) 1989, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-;; Free Software Foundation, Inc.
+;; Copyright (C) 1989, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+;;   2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: Chris Smith <csmith@convex.com>
 ;; Created: 15 Feb 89
@@ -601,7 +601,7 @@
 		  (indent-to this-indent)))
 	    ;; Indent any comment following the text.
 	    (or (looking-at comment-start-skip)
-		(if (re-search-forward comment-start-skip (save-excursion (end-of-line) (point)) t)
+		(if (re-search-forward comment-start-skip (line-end-position) t)
 		    (progn (indent-for-comment) (beginning-of-line))))))))))
 
 (defconst icon-font-lock-keywords-1
@@ -687,5 +687,4 @@
 
 (provide 'icon)
 
-;; arch-tag: 8abf8c99-e7df-44af-a58f-ef5ed2ee52cb
 ;;; icon.el ends here
--- a/lisp/progmodes/idlw-shell.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/progmodes/idlw-shell.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1458,7 +1458,7 @@
 	 (arg (if up arg (- arg))))
     (if (eq t idlwave-shell-arrows-do-history) (goto-char proc-pos))
     (if (and idlwave-shell-arrows-do-history
-	     (>= (1+ (save-excursion (end-of-line) (point))) proc-pos))
+	     (>= (1+ (point-at-eol)) proc-pos))
 	(comint-previous-input arg)
       (forward-line (- arg)))))
 
@@ -2211,7 +2211,7 @@
 
 (defun idlwave-shell-filename-string ()
   "Return t if in a string and after what could be a file name."
-  (let ((limit (save-excursion (beginning-of-line) (point))))
+  (let ((limit (point-at-bol)))
     (save-excursion
       ;; Skip backwards over file name chars
       (skip-chars-backward idlwave-shell-file-name-chars limit)
@@ -2220,7 +2220,7 @@
 
 (defun idlwave-shell-batch-command ()
   "Return t if we're in a batch command statement like @foo"
-  (let ((limit (save-excursion (beginning-of-line) (point))))
+  (let ((limit (point-at-bol)))
     (save-excursion
       ;; Skip backwards over filename
       (skip-chars-backward idlwave-shell-file-name-chars limit)
@@ -2398,7 +2398,7 @@
                                    idlwave-shell-electric-stop-line-face
                                  idlwave-shell-stop-line-face))
 		  (move-overlay idlwave-shell-stop-line-overlay
-				(point) (save-excursion (end-of-line) (point))
+				(point) (point-at-eol)
 				(current-buffer)))
 	      ;; use the arrow instead, but only if marking is wanted.
 	      (if idlwave-shell-mark-stop-line
@@ -4693,5 +4693,4 @@
 (if idlwave-shell-use-toolbar
     (add-hook 'idlwave-shell-mode-hook 'idlwave-toolbar-add-everywhere))
 
-;; arch-tag: 20c2e8ce-0709-41d8-a5b6-bb039148440a
 ;;; idlw-shell.el ends here
--- a/lisp/progmodes/idlwave.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/progmodes/idlwave.el	Mon Nov 08 14:19:54 2010 +0900
@@ -2152,7 +2152,7 @@
   ;;(backward-char 1)
   (let* ((pos (point-marker))
 	 (last-abbrev-marker (copy-marker last-abbrev-location))
-	 (eol-pos (save-excursion (end-of-line) (point)))
+	 (eol-pos (point-at-eol))
 	 begin-pos end-pos end end1 )
     (if idlwave-reindent-end  (idlwave-indent-line))
     (setq last-abbrev-location (marker-position last-abbrev-marker))
@@ -3301,10 +3301,8 @@
         (setq here (point))
         (beginning-of-line)
         (setq bcl (point))
-        (re-search-forward
-         (concat "^[ \t]*" comment-start "+")
-         (save-excursion (end-of-line) (point))
-         t)
+        (re-search-forward (concat "^[ \t]*" comment-start "+")
+			   (point-at-eol) t)
         ;; Get the comment leader on the line and its length
         (setq pre (current-column))
         ;; the comment leader is the indentation plus exactly the
@@ -3369,9 +3367,7 @@
               (setq indent hang)
               (beginning-of-line)
               (while (> (point) start)
-                (re-search-forward comment-start-skip
-                                   (save-excursion (end-of-line) (point))
-                                   t)
+                (re-search-forward comment-start-skip (point-at-eol) t)
                 (if (> (setq diff (- indent (current-column))) 0)
                     (progn
                       (if (>= here (point))
@@ -3393,13 +3389,9 @@
             (setq indent
                   (min indent
                        (progn
-                         (re-search-forward
-                          comment-start-skip
-                          (save-excursion (end-of-line) (point))
-                          t)
+                         (re-search-forward comment-start-skip (point-at-eol) t)
                          (current-column))))
-            (forward-line -1))
-          )
+            (forward-line -1)))
         (setq fill-prefix (concat fill-prefix
                                   (make-string (- indent pre)
                                                ?\ )))
@@ -3407,10 +3399,7 @@
         (setq first-indent
               (max
                (progn
-                 (re-search-forward
-                  comment-start-skip
-                  (save-excursion (end-of-line) (point))
-                  t)
+                 (re-search-forward comment-start-skip (point-at-eol) t)
                  (current-column))
                indent))
 
@@ -3448,17 +3437,11 @@
   (if idlwave-use-last-hang-indent
       (save-excursion
         (end-of-line)
-        (if (re-search-backward
-             idlwave-hang-indent-regexp
-             (save-excursion (beginning-of-line) (point))
-             t)
+        (if (re-search-backward idlwave-hang-indent-regexp (point-at-bol) t)
             (+ (current-column) (length idlwave-hang-indent-regexp))))
     (save-excursion
       (beginning-of-line)
-      (if (re-search-forward
-           idlwave-hang-indent-regexp
-           (save-excursion (end-of-line) (point))
-           t)
+      (if (re-search-forward idlwave-hang-indent-regexp (point-at-eol) t)
           (current-column)))))
 
 (defun idlwave-auto-fill ()
@@ -3502,18 +3485,14 @@
 			 (save-excursion
 			   (forward-line -1)
 			   (idlwave-calc-hanging-indent))))
-		    (if indent
-			(progn
-			  ;; Remove whitespace between comment delimiter and
-			  ;; text, insert spaces for appropriate indentation.
-			  (beginning-of-line)
-			  (re-search-forward
-			   comment-start-skip
-			   (save-excursion (end-of-line) (point)) t)
-			  (delete-horizontal-space)
-			  (idlwave-indent-to indent)
-			  (goto-char (- (point-max) here)))
-		      )))
+		    (when indent
+		      ;; Remove whitespace between comment delimiter and
+		      ;; text, insert spaces for appropriate indentation.
+		      (beginning-of-line)
+		      (re-search-forward comment-start-skip (point-at-eol) t)
+		      (delete-horizontal-space)
+		      (idlwave-indent-to indent)
+		      (goto-char (- (point-max) here)))))
 	    ;; Split code or comment?
 	    (if (save-excursion
 		  (end-of-line 0)
@@ -3767,7 +3746,7 @@
 	   (setq s1 (downcase s1) s2 (downcase s2)))
 	  (idlwave-abbrev-change-case
 	   (setq s1 (upcase s1) s2 (upcase s2))))
-    (let ((beg (save-excursion (beginning-of-line) (point)))
+    (let ((beg (point-at-bol))
 	  end)
       (if (not (looking-at "\\s-*\n"))
 	  (open-line 1))
@@ -6911,9 +6890,10 @@
 ;;----------------------------------------------------------------------
 ;;----------------------------------------------------------------------
 ;;----------------------------------------------------------------------
-(defvar rtn)
-(defun idlwave-pset (item)
-  (set 'rtn item))
+(when (featurep 'xemacs)
+  (defvar rtn)
+  (defun idlwave-pset (item)
+    (set 'rtn item)))
 
 (defun idlwave-popup-select (ev list title &optional sort)
   "Select an item in LIST with a popup menu.
@@ -7683,7 +7663,6 @@
 	  (t nil))))
 
 (defvar link) ;dynamic variables set by help callback
-(defvar props)
 (defun idlwave-complete-sysvar-help (mode word)
   (let ((word (or (nth 1 idlwave-completion-help-info) word))
 	(entry (assoc word idlwave-system-variables-alist)))
@@ -8828,7 +8807,7 @@
   (let* ((entry (car entries))
 	 (name (car entry))      ;
 	 (type (nth 1 entry))    ; Must be bound for
-	 (class (nth 2 entry))   ;  idlwave-routine-twin-compare
+	 (idlwave-twin-class (nth 2 entry)) ;  idlwave-routine-twin-compare
 	 (cnt 0)
 	 source type type-cons file alist syslibp key)
     (while (setq entry (pop entries))
@@ -8870,7 +8849,6 @@
 
 ;; FIXME: Dynamically scoped vars need to use the `idlwave-' prefix.
 ;; (defvar type)
-;; (defvar class)
 (defmacro idlwave-xor (a b)
   `(and (or ,a ,b)
 	(not (and ,a ,b))))
@@ -8903,7 +8881,9 @@
 (defun idlwave-routine-entry-compare-twins (a b)
   "Compare two routine entries, under the assumption that they are twins.
 This basically calls `idlwave-routine-twin-compare' with the correct args."
-  (let* ((name (car a)) (type (nth 1 a)) (class (nth 2 a)) ; needed outside
+  (let* ((name (car a))
+	 (type (nth 1 a))
+	 (idlwave-twin-class (nth 2 a)) ; used in idlwave-routine-twin-compare
 	 (asrc (nth 3 a))
 	 (atype (car asrc))
 	 (bsrc (nth 3 b))
@@ -8916,18 +8896,16 @@
        (list atype afile (list atype)))
      (if (stringp bfile)
 	 (list (file-truename bfile) bfile (list btype))
-       (list btype bfile (list btype))))
-    ))
+       (list btype bfile (list btype))))))
 
 ;; Bound in idlwave-study-twins,idlwave-routine-entry-compare-twins.
-;; FIXME: Dynamically scoped vars need to use the `idlwave-' prefix.
-(defvar class)
+(defvar idlwave-twin-class)
 
 (defun idlwave-routine-twin-compare (a b)
   "Compare two routine twin entries for sorting.
 In here, A and B are not normal routine info entries, but special
 lists (KEY FILENAME (TYPES...)).
-This expects NAME TYPE CLASS to be bound to the right values."
+This expects NAME TYPE IDLWAVE-TWIN-CLASS to be bound to the right values."
   (let* (;; Dis-assemble entries
 	 (akey (car a))	     (bkey (car b))
 	 (afile (nth 1 a))   (bfile (nth 1 b))
@@ -8959,16 +8937,19 @@
 	 ;; Look at file names
 	 (aname (if (stringp afile) (downcase (file-name-nondirectory afile)) ""))
 	 (bname (if (stringp bfile) (downcase (file-name-nondirectory bfile)) ""))
-	 (fname-re (if class (format "\\`%s__\\(%s\\|define\\)\\.pro\\'"
-				     (regexp-quote (downcase class))
-				     (regexp-quote (downcase name)))
+	 (fname-re (if idlwave-twin-class
+		       (format "\\`%s__\\(%s\\|define\\)\\.pro\\'"
+			       (regexp-quote (downcase idlwave-twin-class))
+			       (regexp-quote (downcase name)))
 		     (format "\\`%s\\.pro" (regexp-quote (downcase name)))))
 	 ;; Is file name derived from the routine name?
 	 ;; Method file or class definition file?
 	 (anamep (string-match fname-re aname))
-	 (adefp (and class anamep (string= "define" (match-string 1 aname))))
+	 (adefp (and idlwave-twin-class anamep
+		     (string= "define" (match-string 1 aname))))
 	 (bnamep (string-match fname-re bname))
-	 (bdefp (and class bnamep (string= "define" (match-string 1 bname)))))
+	 (bdefp (and idlwave-twin-class bnamep
+		     (string= "define" (match-string 1 bname)))))
 
     ;; Now: follow JD's ideas about sorting.  Looks really simple now,
     ;; doesn't it?  The difficult stuff is hidden above...
@@ -8980,7 +8961,7 @@
      ((idlwave-xor acompp bcompp)      acompp)	; Compiled entries
      ((idlwave-xor apathp bpathp)      apathp)	; Library before non-library
      ((idlwave-xor anamep bnamep)      anamep)	; Correct file names first
-     ((and class anamep bnamep                  ; both file names match ->
+     ((and idlwave-twin-class anamep bnamep     ; both file names match ->
 	   (idlwave-xor adefp bdefp))  bdefp)	; __define after __method
      ((> anpath bnpath)                t)	; Who is first on path?
      (t                                nil))))	; Default
@@ -9364,5 +9345,4 @@
 
 (provide 'idlwave)
 
-;; arch-tag: f77f3b0c-c37c-424f-a328-0886fd42b6fb
 ;;; idlwave.el ends here
--- a/lisp/progmodes/js.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/progmodes/js.el	Mon Nov 08 14:19:54 2010 +0900
@@ -703,7 +703,7 @@
                (setq str-terminator ?/))
              (re-search-forward
               (concat "\\([^\\]\\|^\\)" (string str-terminator))
-              (save-excursion (end-of-line) (point)) t))
+              (point-at-eol) t))
             ((nth 7 parse)
              (forward-line))
             ((or (nth 4 parse)
@@ -759,7 +759,7 @@
                (setq str-terminator ?/))
              (re-search-backward
               (concat "\\([^\\]\\|^\\)" (string str-terminator))
-              (save-excursion (beginning-of-line) (point)) t))
+              (point-at-bol) t))
             ((nth 7 parse)
              (goto-char (nth 8 parse)))
             ((or (nth 4 parse)
@@ -3377,5 +3377,4 @@
 
 (provide 'js)
 
-;; arch-tag: 1a0d0409-e87f-4fc7-a58c-3731c66ddaac
 ;; js.el ends here
--- a/lisp/progmodes/octave-mod.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/progmodes/octave-mod.el	Mon Nov 08 14:19:54 2010 +0900
@@ -446,17 +446,13 @@
     ;; (fundesc (atom "=" atom))
     ))
 
-(defconst octave-smie-closer-alist
-  (smie-bnf-closer-alist octave-smie-bnf-table))
-
-(defconst octave-smie-op-levels
-  (smie-prec2-levels
+(defconst octave-smie-grammar
+  (smie-prec2->grammar
    (smie-merge-prec2s
-    (smie-bnf-precedence-table
-     octave-smie-bnf-table
-     '((assoc "\n" ";")))
+    (smie-bnf->prec2 octave-smie-bnf-table
+                     '((assoc "\n" ";")))
 
-    (smie-precs-precedence-table octave-operator-table))))
+    (smie-precs->prec2 octave-operator-table))))
 
 ;; Tokenizing needs to be refined so that ";;" is treated as two
 ;; tokens and also so as to recognize the \n separator (and
@@ -521,15 +517,24 @@
    (t
     (smie-default-forward-token))))
 
-(defconst octave-smie-indent-rules
-  '((";"
-     (:parent ("function" "if" "while" "else" "elseif" "for" "otherwise"
-               "case" "try" "catch" "unwind_protect" "unwind_protect_cleanup")
-      ;; FIXME: don't hardcode 2.
-      (+ parent octave-block-offset))
-     ;; (:parent "switch" 4) ;For (invalid) code between switch and case.
-     0)
-    ((:before . "case") octave-block-offset)))
+(defun octave-smie-rules (kind token)
+  (pcase (cons kind token)
+    ;; We could set smie-indent-basic instead, but that would have two
+    ;; disadvantages:
+    ;; - changes to octave-block-offset wouldn't take effect immediately.
+    ;; - edebug wouldn't show the use of this variable.
+    (`(:elem . basic) octave-block-offset)
+    ;; Since "case" is in the same BNF rules as switch..end, SMIE by default
+    ;; aligns it with "switch".
+    (`(:before . "case") (if (not (smie-rule-sibling-p)) octave-block-offset))
+    (`(:after . ";")
+     (if (smie-rule-parent-p "function" "if" "while" "else" "elseif" "for"
+                             "otherwise" "case" "try" "catch" "unwind_protect"
+                             "unwind_protect_cleanup")
+         (smie-rule-parent octave-block-offset)
+       ;; For (invalid) code between switch and case.
+       ;; (if (smie-parent-p "switch") 4)
+       0))))
 
 (defvar electric-indent-chars)
 
@@ -619,36 +624,18 @@
 including a reproducible test case and send the message."
   (setq local-abbrev-table octave-abbrev-table)
 
-  (smie-setup octave-smie-op-levels octave-smie-indent-rules)
+  (smie-setup octave-smie-grammar #'octave-smie-rules
+              :forward-token  #'octave-smie-forward-token
+              :backward-token #'octave-smie-backward-token)
   (set (make-local-variable 'smie-indent-basic) 'octave-block-offset)
-  (set (make-local-variable 'smie-backward-token-function)
-       'octave-smie-backward-token)
-  (set (make-local-variable 'smie-forward-token-function)
-       'octave-smie-forward-token)
-  (set (make-local-variable 'forward-sexp-function)
-       'smie-forward-sexp-command)
-  (set (make-local-variable 'smie-closer-alist) octave-smie-closer-alist)
-  ;; Only needed for interactive calls to blink-matching-open.
-  (set (make-local-variable 'blink-matching-check-function)
-       #'smie-blink-matching-check)
 
-  (when octave-blink-matching-block
-    (add-hook 'post-self-insert-hook #'smie-blink-matching-open 'append 'local)
     (set (make-local-variable 'smie-blink-matching-triggers)
-         (append smie-blink-matching-triggers '(\;)
-                 ;; Rather than wait for SPC or ; to blink, try to blink as
-                 ;; soon as we type the last char of a block ender.
-                 ;; But strip ?d from this list so that we don't blink twice
-                 ;; when the user writes "endif" (once at "end" and another
-                 ;; time at "endif").
-                 (delq ?d (delete-dups
-                           (mapcar (lambda (kw)
-                                     (aref (cdr kw) (1- (length (cdr kw)))))
-                                   smie-closer-alist))))))
+       (cons ?\; smie-blink-matching-triggers))
+  (unless octave-blink-matching-block
+    (remove-hook 'post-self-insert-hook #'smie-blink-matching-open 'local))
 
-  ;; 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/pascal.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/progmodes/pascal.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,8 +1,8 @@
 ;;; pascal.el --- major mode for editing pascal source in Emacs
 
-;; Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
-;;               2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-;;               Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+;;   2002 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+;;   Free Software Foundation, Inc.
 
 ;; Author: Espen Skoglund <esk@gnu.org>
 ;; Keywords: languages
@@ -274,22 +274,12 @@
 ;;;  Macros
 ;;;
 
-(defsubst pascal-get-beg-of-line (&optional arg)
-  (save-excursion
-    (beginning-of-line arg)
-    (point)))
-
-(defsubst pascal-get-end-of-line (&optional arg)
-  (save-excursion
-    (end-of-line arg)
-    (point)))
-
 (defun pascal-declaration-end ()
   (let ((nest 1))
     (while (and (> nest 0)
 		(re-search-forward
 		 "[:=]\\|\\(\\<record\\>\\)\\|\\(\\<end\\>\\)"
-		 (save-excursion (end-of-line 2) (point)) t))
+		 (point-at-eol 2) t))
       (cond ((match-beginning 1) (setq nest (1+ nest)))
 	    ((match-beginning 2) (setq nest (1- nest)))
 	    ((looking-at "[^(\n]+)") (setq nest 0))))))
@@ -298,7 +288,7 @@
 (defun pascal-declaration-beg ()
   (let ((nest 1))
     (while (and (> nest 0)
-		(re-search-backward "[:=]\\|\\<\\(type\\|var\\|label\\|const\\)\\>\\|\\(\\<record\\>\\)\\|\\(\\<end\\>\\)" (pascal-get-beg-of-line 0) t))
+		(re-search-backward "[:=]\\|\\<\\(type\\|var\\|label\\|const\\)\\>\\|\\(\\<record\\>\\)\\|\\(\\<end\\>\\)" (point-at-bol 0) t))
       (cond ((match-beginning 1) (setq nest 0))
 	    ((match-beginning 2) (setq nest (1- nest)))
 	    ((match-beginning 3) (setq nest (1+ nest)))))
@@ -306,8 +296,7 @@
 
 
 (defsubst pascal-within-string ()
-  (save-excursion
-    (nth 3 (parse-partial-sexp (pascal-get-beg-of-line) (point)))))
+  (nth 3 (parse-partial-sexp (point-at-bol) (point))))
 
 
 ;;;###autoload
@@ -407,8 +396,7 @@
 	     (forward-char 1)
 	     (delete-horizontal-space))
 	    ((and (looking-at "(\\*\\|\\*[^)]")
-		  (not (save-excursion
-			 (search-forward "*)" (pascal-get-end-of-line) t))))
+		  (not (save-excursion (search-forward "*)" (point-at-eol) t))))
 	     (setq setstar t))))
     ;; If last line was a star comment line then this one shall be too.
     (if (null setstar)
@@ -727,7 +715,7 @@
     (if (and (looking-at "\\<end;")
 	     (not (save-excursion
 		    (end-of-line)
-		    (search-backward "{" (pascal-get-beg-of-line) t))))
+		    (search-backward "{" (point-at-bol) t))))
 	(let ((type (car (pascal-calculate-indent))))
 	  (if (eq type 'declaration)
 	      ()
@@ -999,7 +987,7 @@
 	   (stpos (progn (goto-char (scan-lists (point) -1 1)) (point)))
 	   (stcol (1+ (current-column)))
 	   (edpos (progn (pascal-declaration-end)
-			 (search-backward ")" (pascal-get-beg-of-line) t)
+			 (search-backward ")" (point-at-bol) t)
 			 (point)))
 	   (usevar (re-search-backward "\\<var\\>" stpos t)))
       (if arg (progn
@@ -1046,7 +1034,7 @@
 	(setq ind (pascal-get-lineup-indent stpos edpos lineup))
 	(goto-char stpos)
 	(while (and (<= (point) edpos) (not (eobp)))
-	  (if (search-forward lineup (pascal-get-end-of-line) 'move)
+	  (if (search-forward lineup (point-at-eol) 'move)
 	      (forward-char -1))
 	  (delete-horizontal-space)
 	  (indent-to ind)
@@ -1073,7 +1061,7 @@
       (goto-char b)
       ;; Get rightmost position
       (while (< (point) e)
-	(and (re-search-forward reg (min e (pascal-get-end-of-line 2)) 'move)
+	(and (re-search-forward reg (min e (point-at-eol 2)) 'move)
 	     (cond ((match-beginning 1)
 		    ;; Skip record blocks
 		    (pascal-declaration-end))
@@ -1137,7 +1125,7 @@
 
       ;; Search through all reachable functions
       (while (pascal-beg-of-defun)
-        (if (re-search-forward pascal-str (pascal-get-end-of-line) t)
+        (if (re-search-forward pascal-str (point-at-eol) t)
             (progn (setq match (buffer-substring (match-beginning 2)
                                                  (match-end 2)))
                    (push match pascal-all)))
@@ -1154,17 +1142,17 @@
 	match)
     ;; Traverse lines
     (while (< (point) end)
-      (if (re-search-forward "[:=]" (pascal-get-end-of-line) t)
+      (if (re-search-forward "[:=]" (point-at-eol) t)
 	  ;; Traverse current line
 	  (while (and (re-search-backward
 		       (concat "\\((\\|\\<\\(var\\|type\\|const\\)\\>\\)\\|"
 			       pascal-symbol-re)
-		       (pascal-get-beg-of-line) t)
+		       (point-at-bol) t)
 		      (not (match-end 1)))
 	    (setq match (buffer-substring (match-beginning 0) (match-end 0)))
 	    (if (string-match (concat "\\<" pascal-str) match)
                 (push match pascal-all))))
-      (if (re-search-forward "\\<record\\>" (pascal-get-end-of-line) t)
+      (if (re-search-forward "\\<record\\>" (point-at-eol) t)
 	  (pascal-declaration-end)
 	(forward-line 1)))
 
@@ -1206,7 +1194,7 @@
           (if (> start (prog1 (save-excursion (pascal-end-of-defun)
                                               (point))))
               ()                        ; Declarations not reachable
-            (if (search-forward "(" (pascal-get-end-of-line) t)
+            (if (search-forward "(" (point-at-eol) t)
                 ;; Check parameterlist
                 ;; FIXME: pascal-get-completion-decl doesn't understand
                 ;; the var declarations in parameter lists :-(
@@ -1264,8 +1252,7 @@
                 (or (eq state 'declaration) (eq state 'paramlist)
                     (and (eq state 'defun)
                          (save-excursion
-                           (re-search-backward ")[ \t]*:"
-                                               (pascal-get-beg-of-line) t))))
+                           (re-search-backward ")[ \t]*:" (point-at-bol) t))))
                 (if (or (eq state 'paramlist) (eq state 'defun))
                     (pascal-beg-of-defun))
                 (nconc
@@ -1554,5 +1541,4 @@
 
 (provide 'pascal)
 
-;; arch-tag: 04535136-fd93-40b4-a505-c9bebdc051f5
 ;;; pascal.el ends here
--- a/lisp/progmodes/perl-mode.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/progmodes/perl-mode.el	Mon Nov 08 14:19:54 2010 +0900
@@ -274,6 +274,11 @@
       ;; Be careful not to match "sub { (...) ... }".
       ("\\<sub\\(?:[[:space:]]+[^{}[:punct:][:space:]]+\\)?[[:space:]]*(\\([^)]+\\))"
        (1 "."))
+      ;; Turn __DATA__ trailer into a comment.
+      ("^\\(_\\)_\\(?:DATA\\|END\\)__[ \t]*\\(?:\\(\n\\)#.-\\*-.*perl.*-\\*-\\|\n.*\\)"
+       (1 "< c") (2 "> c")
+       (0 (ignore (put-text-property (match-beginning 0) (match-end 0)
+                                     'syntax-multiline t))))
       ;; Regexp and funny quotes.  Distinguishing a / that starts a regexp
       ;; match from the division operator is ...interesting.
       ;; Basically, / is a regexp match if it's preceded by an infix operator
@@ -915,9 +920,7 @@
 			   (cond ((looking-at ";?#")
 				  (forward-line 1) t)
 				 ((looking-at "\\(\\w\\|\\s_\\)+:[^:]")
-				  (save-excursion
-				    (end-of-line)
-				    (setq colon-line-end (point)))
+				  (setq colon-line-end (line-end-position))
 				  (search-forward ":")))))
 		  ;; The first following code counts
 		  ;; if it is before the line we want to indent.
@@ -977,7 +980,7 @@
     (if (= (char-after (marker-position bof-mark)) ?=)
 	(message "Can't indent a format statement")
       (message "Indenting Perl expression...")
-      (save-excursion (end-of-line) (setq eol (point)))
+      (setq eol (line-end-position))
       (save-excursion			; locate matching close paren
 	(while (and (not (eobp)) (<= (point) eol))
 	  (parse-partial-sexp (point) (point-max) 0))
@@ -1075,5 +1078,4 @@
 
 (provide 'perl-mode)
 
-;; arch-tag: 8c7ff68d-15f3-46a2-ade2-b7c41f176826
 ;;; perl-mode.el ends here
--- a/lisp/progmodes/prolog.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/progmodes/prolog.el	Mon Nov 08 14:19:54 2010 +0900
@@ -123,7 +123,7 @@
            ((not (zerop (skip-syntax-backward ".")))))
           (point))))
 
-(defconst prolog-smie-op-levels
+(defconst prolog-smie-grammar
   ;; Rather than construct the operator levels table from the BNF,
   ;; we directly provide the operator precedences from GNU Prolog's
   ;; manual (7.14.10 op/3).  The only problem is that GNU Prolog's
@@ -173,10 +173,11 @@
     )
   "Precedence levels of infix operators.")
 
-(defconst prolog-smie-indent-rules
-  '((":-")
-    ("->"))
-  "Prolog indentation rules.")
+(defun prolog-smie-rules (kind token)
+  (pcase (cons kind token)
+    (`(:elem . basic) prolog-indent-width)
+    (`(:after . ".") 0) ;; To work around smie-closer-alist.
+    (`(:after . ,(or `":-" `"->")) prolog-indent-width)))
 
 (defun prolog-mode-variables ()
   (make-local-variable 'paragraph-separate)
@@ -185,19 +186,17 @@
   (setq paragraph-ignore-fill-prefix t)
   (make-local-variable 'imenu-generic-expression)
   (setq imenu-generic-expression '((nil "^\\sw+" 0)))
-  (smie-setup prolog-smie-op-levels prolog-smie-indent-rules)
-  (set (make-local-variable 'smie-forward-token-function)
-       #'prolog-smie-forward-token)
-  (set (make-local-variable 'smie-backward-token-function)
-       #'prolog-smie-backward-token)
-  (set (make-local-variable 'forward-sexp-function)
-       'smie-forward-sexp-command)
-  (set (make-local-variable 'smie-indent-basic) prolog-indent-width)
+
+  ;; Setup SMIE.
+  (smie-setup prolog-smie-grammar #'prolog-smie-rules
+              :forward-token #'prolog-smie-forward-token
+              :backward-token #'prolog-smie-backward-token)
   (set (make-local-variable 'smie-blink-matching-triggers) '(?.))
   (set (make-local-variable 'smie-closer-alist) '((t . ".")))
   (add-hook 'post-self-insert-hook #'smie-blink-matching-open 'append 'local)
   ;; There's no real closer in Prolog anyway.
   (set (make-local-variable 'smie-blink-matching-inners) t)
+
   (make-local-variable 'comment-start)
   (setq comment-start "%")
   (make-local-variable 'comment-start-skip)
@@ -243,7 +242,7 @@
 (defun end-of-prolog-clause ()
   "Go to end of clause in this line."
   (beginning-of-line 1)
-  (let* ((eolpos (save-excursion (end-of-line) (point))))
+  (let* ((eolpos (line-end-position)))
     (if (re-search-forward comment-start-skip eolpos 'move)
 	(goto-char (match-beginning 0)))
     (skip-chars-backward " \t")))
@@ -435,5 +434,4 @@
 
 (provide 'prolog)
 
-;; arch-tag: f3ec6748-1272-4ab6-8826-c50cb1607636
 ;;; prolog.el ends here
--- a/lisp/progmodes/python.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/progmodes/python.el	Mon Nov 08 14:19:54 2010 +0900
@@ -2605,7 +2605,7 @@
               overlay-arrow-string "=>"
               python-pdbtrack-is-tracking-p t)
         (set-marker overlay-arrow-position
-                    (save-excursion (beginning-of-line) (point))
+                    (line-beginning-position)
                     (current-buffer)))
     (setq overlay-arrow-position nil
           python-pdbtrack-is-tracking-p nil)))
@@ -2891,5 +2891,4 @@
 (provide 'python)
 (provide 'python-21)
 
-;; arch-tag: 6fce1d99-a704-4de9-ba19-c6e4912b0554
 ;;; python.el ends here
--- a/lisp/progmodes/ruby-mode.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/progmodes/ruby-mode.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,7 @@
 ;;; ruby-mode.el --- Major mode for editing Ruby files
 
-;; Copyright (C) 1994, 1995, 1996 1997, 1998, 1999, 2000, 2001,
-;;   2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+;; Copyright (C) 1994, 1995, 1996 1997, 1998, 1999, 2000, 2001, 2002,
+;;   2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 
 ;; Authors: Yukihiro Matsumoto
@@ -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)
@@ -618,7 +616,7 @@
           (setq re (regexp-quote (or (match-string 4) (match-string 2))))
           (if (match-beginning 1) (setq re (concat "\\s *" re)))
           (let* ((id-end (goto-char (match-end 0)))
-                 (line-end-position (save-excursion (end-of-line) (point)))
+                 (line-end-position (point-at-eol))
                  (state (list in-string nest depth pcol indent)))
             ;; parse the rest of the line
             (while (and (> line-end-position (point))
@@ -1110,6 +1108,8 @@
               (if mlist (concat mlist mname) mname)
             mlist)))))
 
+(declare-function ruby-syntax-propertize-heredoc "ruby-mode" (limit))
+
 (if (eval-when-compile (fboundp #'syntax-propertize-rules))
     ;; New code that works independently from font-lock.
     (progn
@@ -1164,7 +1164,7 @@
               ;; inf-loop.
               (if (< (point) start) (goto-char start))))))
       )
-      
+
   ;; For Emacsen where syntax-propertize-rules is not (yet) available,
   ;; fallback on the old font-lock-syntactic-keywords stuff.
 
@@ -1256,7 +1256,7 @@
     (save-excursion
       (beginning-of-line)
       (catch 'done
-        (let ((eol (save-excursion (end-of-line) (point)))
+        (let ((eol (point-at-eol))
               (case-fold-search nil)
               ;; Fake match data such that (match-end 0) is at eol
               (end-match-data (progn (looking-at ".*$") (match-data)))
@@ -1430,8 +1430,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 +1454,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))
@@ -1483,5 +1480,4 @@
 
 (provide 'ruby-mode)
 
-;; arch-tag: e6ecc893-8005-420c-b7f9-34ab99a1fff9
 ;;; ruby-mode.el ends here
--- a/lisp/progmodes/simula.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/progmodes/simula.el	Mon Nov 08 14:19:54 2010 +0900
@@ -964,7 +964,7 @@
 	      (simula-previous-statement 1)
 	      (simula-skip-comment-backward)))
 	(setq start-line
-	      (save-excursion (beginning-of-line) (point))
+	      (line-beginning-position)
 	      ;; - perhaps this is a continued statement
 	      continued
 	      (save-excursion
@@ -1023,7 +1023,7 @@
 				 (car simula-continued-statement-offset)
 			       simula-continued-statement-offset))))
 		(setq start-line
-		      (save-excursion (beginning-of-line) (point))
+		      (line-beginning-position)
 		      continued nil))
 	    ;; search failed .. point is at beginning of line
 	    ;; determine if we should continue searching
@@ -1064,7 +1064,7 @@
 			   simula-continued-statement-offset))))
 	    ;; while ends if point is at beginning of line at loop test
 	    (if (not temp)
-		(setq start-line (save-excursion (beginning-of-line) (point)))
+		(setq start-line (line-beginning-position))
 	      (beginning-of-line))))
         ;;
 	;; return indentation
@@ -1659,5 +1659,4 @@
 
 (provide 'simula)
 
-;; arch-tag: 488c1bb0-eebf-4f06-93df-1df603f06255
 ;;; simula.el ends here
--- a/lisp/progmodes/sql.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/progmodes/sql.el	Mon Nov 08 14:19:54 2010 +0900
@@ -7,7 +7,8 @@
 ;; Maintainer: Michael Mauger <mmaug@yahoo.com>
 ;; Version: 2.8
 ;; Keywords: comm languages processes
-;; URL: http://savannah.gnu.org/cgi-bin/viewcvs/emacs/emacs/lisp/progmodes/sql.el
+;; URL: http://savannah.gnu.org/projects/emacs/
+;; URL: http://www.emacswiki.org/cgi-bin/wiki.pl?SqlMode
 
 ;; This file is part of GNU Emacs.
 
@@ -4270,6 +4271,5 @@
 
 (provide 'sql)
 
-;; arch-tag: 7e1fa1c4-9ca2-402e-87d2-83a5eccb7ac3
 ;;; sql.el ends here
 
--- a/lisp/progmodes/vera-mode.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/progmodes/vera-mode.el	Mon Nov 08 14:19:54 2010 +0900
@@ -770,7 +770,7 @@
 	      relpos 0)
       (setq offset (vera-evaluate-offset offset langelem symbol)))
     (+ (if (and relpos
-		(< relpos (save-excursion (beginning-of-line) (point))))
+		(< relpos (line-beginning-position)))
 	   (save-excursion
 	     (goto-char relpos)
 	     (current-column))
@@ -1482,5 +1482,4 @@
 
 (provide 'vera-mode)
 
-;; arch-tag: 22eae722-7ac5-47ac-a713-c4db1cf623a9
 ;;; vera-mode.el ends here
--- a/lisp/progmodes/verilog-mode.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/progmodes/verilog-mode.el	Mon Nov 08 14:19:54 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,9 @@
 ;;  Macros
 ;;
 
+(defsubst verilog-within-string ()
+  (nth 3 (parse-partial-sexp (point-at-bol) (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 +1457,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 (point-at-eol) 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 (point-at-bol) 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 +1507,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 +1523,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 +1545,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 +1616,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 +1631,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 +1810,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 +1949,8 @@
    "\\(\\<fork\\>\\)\\|"			 ; 7
    "\\(\\<always\\>\\(\[ \t\]*@\\)?\\)\\|"
    "\\(\\<if\\>\\)\\|"
+   verilog-property-re "\\|"
+   "\\(\\(" verilog-label-re "\\)?\\<assert\\>\\)\\|"
    "\\(\\<clocking\\>\\)\\|"
    "\\(\\<task\\>\\)\\|"
    "\\(\\<function\\>\\)\\|"
@@ -2051,7 +2165,7 @@
        "`case"
        "`default"
        "`define" "`undef"
-       "`if" "`ifdef" "`ifndef" "`else" "`endif"
+       "`if" "`ifdef" "`ifndef" "`else" "`elsif" "`endif"
        "`while" "`endwhile"
        "`for" "`endfor"
        "`format"
@@ -2120,7 +2234,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 +2582,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 +2594,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 +3154,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 +3593,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 +3652,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 +3754,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 +3770,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 +3896,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.
@@ -3645,7 +3914,7 @@
        (or  kill-existing-comment
 	    (not (save-excursion
 		   (end-of-line)
-		   (search-backward "//" (verilog-get-beg-of-line) t)))))
+		   (search-backward "//" (point-at-bol) t)))))
       (let ((nest 1) b e
 	    m
 	    (else (if (match-end 2) "!" " ")))
@@ -3668,7 +3937,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 +3959,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
@@ -3693,7 +3967,7 @@
 	   (or kill-existing-comment
 	       (not (save-excursion
 		      (end-of-line)
-		      (search-backward "//" (verilog-get-beg-of-line) t)))))
+		      (search-backward "//" (point-at-bol) t)))))
       (let ((type (car indent-str)))
 	(unless (eq type 'declaration)
 	  (unless (looking-at (concat "\\(" verilog-end-block-ordered-re "\\)[ \t]*:")) ;; ignore named ends
@@ -3764,8 +4038,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 +4063,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 +4079,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 +4109,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 +4252,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))
@@ -4205,7 +4501,7 @@
                 (cond
                  ((looking-at "// surefire lint_off_line ")
                   (goto-char (match-end 0))
-                  (let ((lim (save-excursion (end-of-line) (point))))
+                  (let ((lim (point-at-eol)))
                     (if (re-search-forward code lim 'move)
                         (throw 'already t)
                       (insert (concat " " code)))))
@@ -4243,6 +4539,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 +4703,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 +4767,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 +4901,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 +4931,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 +5180,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 +5304,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 +5348,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 +5363,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 +5379,7 @@
  (save-excursion
    (if (verilog-in-paren)
        (progn
-	 (backward-up-list 1)
+	 (verilog-backward-up-list 1)
 	 (verilog-at-struct-p)
 	 )
      nil)))
@@ -5056,7 +5390,7 @@
  (save-excursion
    (if (verilog-in-paren)
        (progn
-	 (backward-up-list 1)
+	 (verilog-backward-up-list 1)
 	 (verilog-at-constraint-p)
 	 )
      nil)))
@@ -5147,30 +5481,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 +5611,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 +5636,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 +5804,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 +5822,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 +5853,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 +5872,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 +5893,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 +5927,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 +6257,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 +6620,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 +6864,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 +6894,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 +7077,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 +7123,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 +7214,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 +7223,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 +7231,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 +7245,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 +7303,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 +7323,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 +7335,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 +7382,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 +7466,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 +7500,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 +7510,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 +7536,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 +7558,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 +7609,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 +7618,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 +7712,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 +7740,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 +7831,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 +7843,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 +7858,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 +7877,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 +7930,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 +8083,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 +8107,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)))))))
 
@@ -7671,8 +8261,7 @@
 		       ": Can't find verilog-getopt-file -f file: " filename)))
       (goto-char (point-min))
       (while (not (eobp))
-	(setq line (buffer-substring (point)
-				     (save-excursion (end-of-line) (point))))
+	(setq line (buffer-substring (point) (point-at-eol)))
 	(forward-line 1)
 	(when (string-match "//" line)
 	  (setq line (substring line 0 (match-beginning 0))))
@@ -7702,6 +8291,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 +8324,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 +8374,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 +8557,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 +8565,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 +8648,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 +8672,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 +8692,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 +8715,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 +8741,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 +8887,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 +8901,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 +9133,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 +9235,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 +9257,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 +9291,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 +9309,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 +9462,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 +9526,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 +9582,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 +9604,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 +9623,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 +9632,7 @@
 
 Typing \\[verilog-auto] will make this into:
 
-	module ExampInst (o,i)
+	module ExampInst (o,i);
 	   output o;
 	   input i;
 	   InstModule instName
@@ -9238,7 +9883,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 +9895,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 +9927,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 +9938,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 +9949,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 +9977,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 +9991,7 @@
 
 Typing \\[verilog-auto] will make this into:
 
-	module ExampInst (o,i)
+	module ExampInst (o,i);
 	   output o;
 	   input i;
 	   InstModule #(/*AUTOINSTPARAM*/
@@ -9398,9 +10054,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 +10083,7 @@
 
 An example:
 
-	module ExampReg (o,i)
+	module ExampReg (o,i);
 	   output o;
 	   input i;
 	   /*AUTOREG*/
@@ -9437,7 +10092,7 @@
 
 Typing \\[verilog-auto] will make this into:
 
-	module ExampReg (o,i)
+	module ExampReg (o,i);
 	   output o;
 	   input i;
 	   /*AUTOREG*/
@@ -9459,6 +10114,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 +10137,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 +10147,7 @@
 
 Typing \\[verilog-auto] will make this into:
 
-	module ExampRegInput (o,i)
+	module ExampRegInput (o,i);
 	   output o;
 	   input i;
 	   /*AUTOREGINPUT*/
@@ -9543,7 +10199,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 +10209,7 @@
 
 Typing \\[verilog-auto] will make this into:
 
-	module ExampWire (o,i)
+	module ExampWire (o,i);
 	   output o;
 	   input i;
 	   /*AUTOWIRE*/
@@ -9613,7 +10269,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 +10278,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 +10335,7 @@
 
 An example:
 
-	module ExampOutputEvery (o,i,tempa,tempb)
+	module ExampOutputEvery (o,i,tempa,tempb);
 	   output o;
 	   input i;
 	   /*AUTOOUTPUTEVERY*/
@@ -9690,7 +10346,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 +10398,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 +10407,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 +10442,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 +10479,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 +10488,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 +10543,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 +10559,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 +10571,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 +10662,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 +10679,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 +10691,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 +10765,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 +10775,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 +10858,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 +10958,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 +10975,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 +10991,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 +11034,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 +11290,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 +11332,7 @@
 called before and after this function, respectively.
 
 For example:
-	module ModuleName (/*AUTOARG*/)
+	module ModuleName (/*AUTOARG*/);
 	/*AUTOINPUT*/
 	/*AUTOOUTPUT*/
 	/*AUTOWIRE*/
@@ -10717,89 +11388,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 +11875,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 (point-at-eol))
+	    (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 +12017,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 +12063,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,
@@ -11375,5 +12110,4 @@
 ;; checkdoc-force-docstrings-flag:nil
 ;; End:
 
-;; arch-tag: 87923725-57b3-41b5-9494-be21118c6a6f
 ;;; verilog-mode.el ends here
--- a/lisp/progmodes/vhdl-mode.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/progmodes/vhdl-mode.el	Mon Nov 08 14:19:54 2010 +0900
@@ -7269,7 +7269,7 @@
        (save-excursion
 	 (goto-char begin)
 	 (let (element
-	       (eol (save-excursion (progn (end-of-line) (point)))))
+	       (eol (point-at-eol)))
 	   (setq element (nth 0 copy))
 	   (when (and (or (and (listp (car element))
 			       (memq major-mode (car element)))
@@ -7295,7 +7295,7 @@
       ;; Determine the greatest whitespace distance to the alignment
       ;; character
       (goto-char begin)
-      (setq eol (progn (end-of-line) (point))
+      (setq eol (point-at-eol)
 	    bol (setq begin (progn (beginning-of-line) (point))))
       (while (< bol end)
 	(save-excursion
@@ -7306,13 +7306,13 @@
 	      (setq max distance))))
 	(forward-line)
 	(setq bol (point)
-	      eol (save-excursion (end-of-line) (point)))
+	      eol (point-at-eol))
 	(setq lines (1+ lines)))
       ;; Now insert enough maxs to push each assignment operator to
       ;; the same column.  We need to use 'lines' as a counter, since
       ;; the location of the mark may change
       (goto-char (setq bol begin))
-      (setq eol (save-excursion (end-of-line) (point)))
+      (setq eol (point-at-eol))
       (while (> lines 0)
   	(when (and (re-search-forward match eol t)
 		   (not (vhdl-in-literal)))
@@ -7324,7 +7324,7 @@
 	(beginning-of-line)
 	(forward-line)
 	(setq bol (point)
-	      eol (save-excursion (end-of-line) (point)))
+	      eol (point-at-eol))
 	(setq lines (1- lines))))))
 
 (defun vhdl-align-region-groups (beg end &optional spacing
@@ -7988,7 +7988,7 @@
 	   (forward-char)
 	   (vhdl-forward-syntactic-ws))
 	 (goto-char end)
-	 (when (> pos (save-excursion (end-of-line) (point)))
+	 (when (> pos (point-at-eol))
 	   (error "ERROR:  Not within a generic/port clause"))
 	 ;; delete closing parenthesis on separate line (not supported style)
 	 (when (save-excursion (beginning-of-line) (looking-at "^\\s-*);"))
@@ -15916,7 +15916,7 @@
 							 &optional insert-conf)
   "Generate block configuration for architecture."
   (let ((margin (current-indentation))
-	(beg (save-excursion (beginning-of-line) (point)))
+	(beg (point-at-bol))
 	ent-entry inst-entry inst-path inst-prev-path cons-key tmp-alist)
     ;; insert block configuration (for architecture)
     (vhdl-insert-keyword "FOR ") (insert arch-name "\n")
@@ -16977,5 +16977,4 @@
 
 (provide 'vhdl-mode)
 
-;; arch-tag: 780d7073-9b5d-4c6c-b0d8-26b28783aba3
 ;;; vhdl-mode.el ends here
--- a/lisp/ps-mule.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/ps-mule.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/ps-print.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/repeat.el	Mon Nov 08 14:19:54 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/reposition.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/reposition.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,7 @@
 ;;; reposition.el --- center a Lisp function or comment on the screen
 
-;; Copyright (C) 1991, 1994, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1991, 1994, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+;;   2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: Michael D. Ernst <mernst@theory.lcs.mit.edu>
 ;; Created: Jan 1991
@@ -58,7 +58,7 @@
 comments, including the first comment line, are visible), or to make the
 first comment line visible (if point is in a comment)."
   (interactive "P")
-  (let* (;; (here (save-excursion (beginning-of-line) (point)))
+  (let* (;; (here (line-beginning-position))
 	 (here (point))
 	 ;; change this name once I've gotten rid of references to ht.
 	 ;; this is actually the number of the last screen line
@@ -193,5 +193,4 @@
 
 (provide 'reposition)
 
-;; arch-tag: 79487039-3bd7-4ab5-a3e8-ecf3b4919010
 ;;; reposition.el ends here
--- a/lisp/select.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/select.el	Mon Nov 08 14:19:54 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,17 +66,18 @@
          (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))
 
-;; This is for temporary compatibility with pre-release Emacs 19.
-(defalias 'x-selection 'x-get-selection)
+;; Only declared obsolete in 23.3.
+(define-obsolete-function-alias 'x-selection 'x-get-selection "at least 19.34")
+
 (defun x-get-selection (&optional type data-type)
   "Return the value of an X Windows selection.
 The argument TYPE (default `PRIMARY') says which selection,
@@ -380,5 +389,4 @@
 
 (provide 'select)
 
-;; arch-tag: bb634f97-8a3b-4b0a-b940-f6e09982328c
 ;;; select.el ends here
--- a/lisp/server.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/server.el	Mon Nov 08 14:19:54 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/shell.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/shell.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,8 @@
 ;;; shell.el --- specialized comint.el for running the shell
 
-;; Copyright (C) 1988, 1993, 1994, 1995, 1996, 1997, 2000, 2001,
-;;   2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1988, 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2002,
+;;   2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+;;   Free Software Foundation, Inc.
 
 ;; Author: Olin Shivers <shivers@cs.cmu.edu>
 ;;	Simon Marshall <simon@gnu.org>
@@ -700,7 +701,7 @@
 (defun shell-process-popd (arg)
   (let ((num (or (shell-extract-num arg) 0)))
     (cond ((and num (= num 0) shell-dirstack)
-	   (shell-cd (car shell-dirstack))
+	   (shell-cd (shell-prefixed-directory-name (car shell-dirstack)))
 	   (setq shell-dirstack (cdr shell-dirstack))
 	   (shell-dirstack-message))
 	  ((and num (> num 0) (<= num (length shell-dirstack)))
@@ -928,7 +929,7 @@
   "Move forward across ARG shell command(s).  Does not cross lines.
 See `shell-command-regexp'."
   (interactive "p")
-  (let ((limit (save-excursion (end-of-line nil) (point))))
+  (let ((limit (line-end-position)))
     (if (re-search-forward (concat shell-command-regexp "\\([;&|][\t ]*\\)+")
 			   limit 'move arg)
 	(skip-syntax-backward " "))))
@@ -1111,5 +1112,4 @@
 
 (provide 'shell)
 
-;; arch-tag: bcb5f12a-c1f4-4aea-a809-2504bd5bd797
 ;;; shell.el ends here
--- a/lisp/simple.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/simple.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,8 +1,8 @@
 ;;; simple.el --- basic editing commands for Emacs
 
-;; Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-;;   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-;;   Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1996, 1997, 1998,
+;;   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
+;;   2010  Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: internal
@@ -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
@@ -4053,29 +4051,8 @@
 \"mark.*active\" at the prompt, to see the documentation of
 commands which are sensitive to the Transient Mark mode."
   :global t
-  :init-value (not noninteractive)
-  :initialize 'custom-initialize-delay
-  :group 'editing-basics)
-
-;; The variable transient-mark-mode is ugly: it can take on special
-;; values.  Document these here.
-(defvar transient-mark-mode t
-  "*Non-nil if Transient Mark mode is enabled.
-See the command `transient-mark-mode' for a description of this minor mode.
-
-Non-nil also enables highlighting of the region whenever the mark is active.
-The variable `highlight-nonselected-windows' controls whether to highlight
-all windows or just the selected window.
-
-If the value is `lambda', that enables Transient Mark mode temporarily.
-After any subsequent action that would normally deactivate the mark
-\(such as buffer modification), Transient Mark mode is turned off.
-
-If the value is (only . OLDVAL), that enables Transient Mark mode
-temporarily.  After any subsequent point motion command that is not
-shift-translated, or any other action that would normally deactivate
-the mark (such as buffer modification), the value of
-`transient-mark-mode' is set to OLDVAL.")
+  ;; It's defined in C/cus-start, this stops the d-m-m macro defining it again.
+  :variable transient-mark-mode)
 
 (defvar widen-automatically t
   "Non-nil means it is ok for commands to call `widen' when they want to.
@@ -4497,7 +4474,7 @@
 
       (let (new
 	    (old (point))
-	    (line-beg (save-excursion (beginning-of-line) (point)))
+	    (line-beg (line-beginning-position))
 	    (line-end
 	     ;; Compute the end of the line
 	     ;; ignoring effectively invisible newlines.
@@ -4605,7 +4582,7 @@
 	;; that will get us to the same place on the screen
 	;; but with a more reasonable buffer position.
 	(goto-char normal-location)
-	(let ((line-beg (save-excursion (beginning-of-line) (point))))
+	(let ((line-beg (line-beginning-position)))
 	  (while (and (not (bolp)) (invisible-p (1- (point))))
 	    (goto-char (previous-char-property-change (point) line-beg))))))))
 
@@ -6628,7 +6605,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 +6741,4 @@
 
 (provide 'simple)
 
-;; arch-tag: 24af67c0-2a49-44f6-b3b1-312d8b570dfd
 ;;; simple.el ends here
--- a/lisp/skeleton.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/skeleton.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,7 @@
 ;;; skeleton.el --- Lisp language extension for writing statement skeletons -*- coding: utf-8 -*-
 
-;; Copyright (C) 1993, 1994, 1995, 1996, 2001, 2002, 2003,
-;;   2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1994, 1995, 1996, 2001, 2002, 2003, 2004, 2005,
+;;   2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: Daniel Pfeiffer <occitan@esperanto.org>
 ;; Maintainer: FSF
@@ -318,7 +318,7 @@
     prompt))
 
 (defun skeleton-internal-list (skeleton &optional str recursive)
-  (let* ((start (save-excursion (beginning-of-line) (point)))
+  (let* ((start (line-beginning-position))
 	 (column (current-column))
 	 (line (buffer-substring start (line-end-position)))
 	 opoint)
@@ -562,5 +562,4 @@
 
 (provide 'skeleton)
 
-;; arch-tag: ccad7bd5-eb5d-40de-9ded-900197215c3e
 ;;; skeleton.el ends here
--- a/lisp/sort.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/sort.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,7 @@
 ;;; sort.el --- commands to sort text in an Emacs buffer
 
-;; Copyright (C) 1986, 1987, 1994, 1995, 2001, 2002, 2003,
-;;   2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1986, 1987, 1994, 1995, 2001, 2002, 2003, 2004, 2005,
+;;   2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: Howie Kaye
 ;; Maintainer: FSF
@@ -361,8 +361,8 @@
 	(if (eolp)
 	    (error "Line has too few fields: %s"
 		   (buffer-substring
-		    (save-excursion (beginning-of-line) (point))
-		    (save-excursion (end-of-line) (point))))))
+		    (line-beginning-position)
+		    (line-end-position)))))
     (end-of-line)
     ;; Skip back across - N - 1 fields.
     (let ((i (1- (- n))))
@@ -374,8 +374,8 @@
     (if (bolp)
 	(error "Line has too few fields: %s"
 	       (buffer-substring
-		(save-excursion (beginning-of-line) (point))
-		(save-excursion (end-of-line) (point)))))
+		(line-beginning-position)
+		(line-end-position))))
     ;; Position at the front of the field
     ;; even if moving backwards.
     (skip-chars-backward "^ \t\n")))
@@ -559,5 +559,4 @@
 
 (provide 'sort)
 
-;; arch-tag: fbac12be-2a7b-4c8a-9665-264d61f70bd9
 ;;; sort.el ends here
--- a/lisp/speedbar.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/speedbar.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,8 @@
 ;;; speedbar --- quick access to files and tags in a frame
 
 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;;   2005, 2006, 2007, 2008, 2009, 2010
+;;   Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <zappo@gnu.org>
 ;; Keywords: file, tags, tools
@@ -1128,9 +1129,9 @@
     (setq font-lock-keywords nil) ;; no font-locking please
     (setq truncate-lines t)
     (make-local-variable 'frame-title-format)
-    (setq frame-title-format (concat "Speedbar " speedbar-version))
-    (setq case-fold-search nil)
-    (toggle-read-only 1)
+    (setq frame-title-format (concat "Speedbar " speedbar-version)
+	  case-fold-search nil
+	  buffer-read-only t)
     (speedbar-set-mode-line-format)
     ;; Add in our dframe hooks.
     (if speedbar-track-mouse-flag
@@ -1471,7 +1472,7 @@
     (if (looking-at "\\s-*[[<({].[]>)}] ") (goto-char (match-end 0)))
     ;; Get the text
     (speedbar-message "Text: %s" (buffer-substring-no-properties
-				  (point) (progn (end-of-line) (point))))))
+				  (point) (line-end-position)))))
 
 (defun speedbar-item-info ()
   "Display info in the minibuffer about the button the mouse is over.
@@ -1497,8 +1498,7 @@
 Return nil if not applicable."
   (save-excursion
     (beginning-of-line)
-    (if (re-search-forward " [-+=]?> \\([^\n]+\\)"
-			   (save-excursion(end-of-line)(point)) t)
+    (if (re-search-forward " [-+=]?> \\([^\n]+\\)" (line-end-position) t)
        (let* ((tag (match-string 1))
 	      (attr (speedbar-line-token))
 	      (item nil)
@@ -1516,8 +1516,7 @@
 	    (looking-at "\\([0-9]+\\):")
 	    (setq item (file-name-nondirectory (speedbar-line-directory)))
 	    (speedbar-message "Tag: %s  in %s" tag item)))
-      (if (re-search-forward "{[+-]} \\([^\n]+\\)$"
-			     (save-excursion(end-of-line)(point)) t)
+      (if (re-search-forward "{[+-]} \\([^\n]+\\)$" (line-end-position) t)
 	  (speedbar-message "Group of tags \"%s\"" (match-string 1))
 	(if (re-search-forward " [+-]?[()|@] \\([^\n]+\\)$" nil t)
 	    (let* ((detailtext (match-string 1))
@@ -2061,8 +2060,7 @@
   "Change the expansion button character to CHAR for the current line."
   (save-excursion
     (beginning-of-line)
-    (if (re-search-forward ":\\s-*.\\([-+?]\\)" (save-excursion (end-of-line)
-								(point)) t)
+    (if (re-search-forward ":\\s-*.\\([-+?]\\)" (line-end-position) t)
 	(speedbar-with-writable
 	  (goto-char (match-end 1))
 	  (insert-char char 1 t)
@@ -2851,9 +2849,7 @@
   (speedbar-with-writable
     (save-excursion
       (if (and replace-this
-	       (re-search-forward replace-this (save-excursion (end-of-line)
-							       (point))
-				  t))
+	       (re-search-forward replace-this (line-end-position) t))
 	  (delete-region (match-beginning 0) (match-end 0))))
     (end-of-line)
     (if (not (string= " " indicator-string))
@@ -2951,9 +2947,7 @@
 	 (fn (buffer-substring-no-properties
 	      ;; Skip-chars: thanks ptype@dra.hmg.gb
 	      (point) (progn
-			(skip-chars-forward "^ "
-					    (save-excursion (end-of-line)
-							    (point)))
+			(skip-chars-forward "^ " (line-end-position))
 			(point))))
 	 (fulln (concat f fn)))
     (if (<= 2 speedbar-verbosity-level)
@@ -3025,9 +3019,7 @@
 	 (fn (buffer-substring-no-properties
 	      ;; Skip-chars: thanks ptype@dra.hmg.gb
 	      (point) (progn
-			(skip-chars-forward "^ "
-					    (save-excursion (end-of-line)
-							    (point)))
+			(skip-chars-forward "^ " (line-end-position))
 			(point))))
 	 (fulln (concat f fn)))
     (if (<= 2 speedbar-verbosity-level)
@@ -3248,7 +3240,7 @@
 	;; If this fails, then it is a non-standard click, and as such,
 	;; perfectly allowed.
 	(if (re-search-forward "[]>?}] [^ ]"
-			       (save-excursion (end-of-line) (point))
+			       (line-end-position)
 			       t)
 	    (progn
 	      (forward-char -1)
@@ -3266,7 +3258,7 @@
     (condition-case nil
 	(progn
 	  (re-search-forward ":\\s-*.\\+. "
-			     (save-excursion (end-of-line) (point)))
+			     (line-end-position))
 	  (forward-char -2)
 	  (speedbar-do-function-pointer))
       (error (speedbar-position-cursor-on-line)))))
@@ -3283,7 +3275,7 @@
   (condition-case nil
       (progn
 	(re-search-forward ":\\s-*.-. "
-			   (save-excursion (end-of-line) (point)))
+			   (line-end-position))
 	(forward-char -2)
 	(speedbar-do-function-pointer))
     (error (speedbar-position-cursor-on-line))))
@@ -3295,7 +3287,7 @@
   (condition-case nil
       (progn
 	(re-search-forward ":\\s-*.[-+]. "
-			   (save-excursion (end-of-line) (point)))
+			   (line-end-position))
 	(forward-char -2)
 	(speedbar-do-function-pointer))
     (error (speedbar-position-cursor-on-line))))
@@ -3763,17 +3755,12 @@
 regular expression EXPR."
   (let* ((sym (if (stringp expr)
 		  (if (save-excursion
-			(re-search-forward expr (save-excursion
-						  (end-of-line)
-						  (point)) t))
+			(re-search-forward expr (line-end-position) t))
 		      (buffer-substring-no-properties (match-beginning 1)
 						      (match-end 1)))
 		(funcall expr)))
 	 (pos (let ((j (re-search-forward "[\C-?\C-a]\\([0-9]+\\),\\([0-9]+\\)"
-					  (save-excursion
-					    (end-of-line)
-					    (point))
-					  t)))
+					  (line-end-position) t)))
 		(if (and j sym)
 		    (1+ (string-to-number (buffer-substring-no-properties
 					(match-beginning 2)
@@ -3786,7 +3773,7 @@
 (defun speedbar-parse-c-or-c++tag ()
   "Parse a C or C++ tag, which tends to be a little complex."
   (save-excursion
-    (let ((bound (save-excursion (end-of-line) (point))))
+    (let ((bound (line-end-position)))
       (cond ((re-search-forward "\C-?\\([^\C-a]+\\)\C-a" bound t)
 	     (buffer-substring-no-properties (match-beginning 1)
 					     (match-end 1)))
@@ -3802,7 +3789,7 @@
 (defun speedbar-parse-tex-string ()
   "Parse a Tex string.  Only find data which is relevant."
   (save-excursion
-    (let ((bound (save-excursion (end-of-line) (point))))
+    (let ((bound (line-end-position)))
       (cond ((re-search-forward "\\(\\(sub\\)*section\\|chapter\\|cite\\)\\s-*{[^\C-?}]*}?" bound t)
 	     (buffer-substring-no-properties (match-beginning 0)
 					     (match-end 0)))
@@ -3947,9 +3934,7 @@
 	(let* ((bn (speedbar-line-text))
 	       (buffer (if bn (get-buffer bn))))
 	  (if buffer
-	      (if (save-excursion
-		    (end-of-line)
-		    (eq start (point)))
+	      (if (eq start (line-end-position))
 		  (or (with-current-buffer buffer default-directory)
 		      "")
 		(buffer-file-name buffer))))))))
@@ -3981,14 +3966,10 @@
     (beginning-of-line)
     ;; If this fails, then it is a non-standard click, and as such,
     ;; perfectly allowed
-    (if (re-search-forward "[]>?}] [^ ]"
-			   (save-excursion (end-of-line) (point))
-			   t)
+    (if (re-search-forward "[]>?}] [^ ]" (line-end-position) t)
 	(let ((text (progn
 		      (forward-char -1)
-		      (buffer-substring (point) (save-excursion
-						  (end-of-line)
-						  (point))))))
+		      (buffer-substring (point) (line-end-position)))))
 	  (if (get-buffer text)
 	      (progn
 		(set-buffer text)
@@ -4004,7 +3985,7 @@
   "Highlight the current line, unhighlighting a previously jumped to line."
   (speedbar-unhighlight-one-tag-line)
   (setq speedbar-highlight-one-tag-line
-	(speedbar-make-overlay (save-excursion (beginning-of-line) (point))
+	(speedbar-make-overlay (line-beginning-position)
 			       (save-excursion (end-of-line)
 					       (forward-char 1)
 					       (point))))
@@ -4142,5 +4123,4 @@
 ;; run load-time hooks
 (run-hooks 'speedbar-load-hook)
 
-;; arch-tag: 4477e6d1-f78c-48b9-a503-387d3c9767d5
 ;;; speedbar ends here
--- a/lisp/startup.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/startup.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,7 @@
 ;;; startup.el --- process Emacs shell arguments
 
-;; Copyright (C) 1985, 1986, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-;;   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+;; Copyright (C) 1985, 1986, 1992, 1994, 1995, 1996, 1997, 1998, 1999,
+;;   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
@@ -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)
@@ -691,6 +691,9 @@
 
 (defvar server-name)
 (defvar server-process)
+;; Autoload in package.el, but when we bootstrap, we don't have loaddefs yet.
+(defvar package-enable-at-startup)
+(declare-function package-initialize "package" ())
 
 (defun command-line ()
   (setq before-init-time (current-time)
@@ -1172,8 +1175,30 @@
 		 (eq face-ignored-fonts old-face-ignored-fonts))
       (clear-face-cache)))
 
-  ;; Load ELPA packages.
-  (and user-init-file package-enable-at-startup (package-initialize))
+  ;; If any package directory exists, initialize the package system.
+  (and user-init-file
+       package-enable-at-startup
+       (catch 'package-dir-found
+	 (let (dirs)
+	   (if (boundp 'package-directory-list)
+	       (setq dirs package-directory-list)
+	     (dolist (f load-path)
+	       (and (stringp f)
+		    (equal (file-name-nondirectory f) "site-lisp")
+		    (push (expand-file-name "elpa" f) dirs))))
+	   (push (if (boundp 'package-user-dir)
+		     package-user-dir
+		   (locate-user-emacs-file "elpa"))
+		 dirs)
+	   (dolist (dir dirs)
+	     (when (file-directory-p dir)
+	       (dolist (subdir (directory-files dir))
+		 (when (and (file-directory-p (expand-file-name subdir dir))
+			    ;; package-subdirectory-regexp from package.el
+			    (string-match "^\\([^.].*\\)-\\([0-9]+\\(?:[.][0-9]+\\)*\\)$"
+					  subdir))
+		   (throw 'package-dir-found t)))))))
+       (package-initialize))
 
   (setq after-init-time (current-time))
   (run-hooks 'after-init-hook)
@@ -1563,21 +1588,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.")))))
 
@@ -2354,5 +2384,4 @@
       (setq file (replace-match "/" t t file)))
     file))
 
-;; arch-tag: 7e294698-244d-4758-984b-4047f887a5db
 ;;; startup.el ends here
--- a/lisp/subr.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/subr.el	Mon Nov 08 14:19:54 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."
@@ -3596,18 +3593,18 @@
 ;;;; Comparing version strings.
 
 (defconst version-separator "."
-  "*Specify the string used to separate the version elements.
+  "Specify the string used to separate the version elements.
 
 Usually the separator is \".\", but it can be any other string.")
 
 
 (defconst version-regexp-alist
-  '(("^[-_+ ]?alpha$"   . -3)
-    ("^[-_+]$"                 . -3) ; treat "1.2.3-20050920" and "1.2-3" as alpha releases
-    ("^[-_+ ]cvs$"             . -3)	; treat "1.2.3-CVS" as alpha release
-    ("^[-_+ ]?beta$"    . -2)
+  '(("^[-_+ ]?alpha$"           . -3)
+    ("^[-_+]$"                  . -3) ; treat "1.2.3-20050920" and "1.2-3" as alpha releases
+    ("^[-_+ ]cvs$"              . -3) ; treat "1.2.3-CVS" as alpha release
+    ("^[-_+ ]?beta$"            . -2)
     ("^[-_+ ]?\\(pre\\|rcc\\)$" . -1))
-  "*Specify association between non-numeric version and its priority.
+  "Specify association between non-numeric version and its priority.
 
 This association is used to handle version string like \"1.0pre2\",
 \"0.9alpha1\", etc.  It's used by `version-to-list' (which see) to convert the
@@ -3701,7 +3698,7 @@
 	      (setq al (cdr al)))
 	    (cond (al
 		   (push (cdar al) lst))
-		  ;; Convert 22.3a to 22.3.1.
+		  ;; Convert 22.3a to 22.3.1, 22.3b to 22.3.2, etc.
 		  ((string-match "^[-_+ ]?\\([a-zA-Z]\\)$" s)
 		   (push (- (aref (downcase (match-string 1 s)) 0) ?a -1)
 			 lst))
@@ -3757,7 +3754,7 @@
   "Return t if L1, a list specification of a version, is lower or equal to L2.
 
 Note that integer list (1) is equal to (1 0), (1 0 0), (1 0 0 0),
-etc.  That is, the trailing zeroes are irrelevant.  Also, integer
+etc.  That is, the trailing zeroes are insignificant.  Also, integer
 list (1) is greater than (1 -1) which is greater than (1 -2)
 which is greater than (1 -3)."
   (while (and l1 l2 (= (car l1) (car l2)))
@@ -3799,7 +3796,7 @@
   "Return t if version V1 is lower (older) than or equal to V2.
 
 Note that version string \"1\" is equal to \"1.0\", \"1.0.0\", \"1.0.0.0\",
-etc.  That is, the trailing \".0\"s are insignificant..  Also, version
+etc.  That is, the trailing \".0\"s are insignificant.  Also, version
 string \"1\" is higher (newer) than \"1pre\", which is higher than \"1beta\",
 which is higher than \"1alpha\"."
   (version-list-<= (version-to-list v1) (version-to-list v2)))
@@ -3808,7 +3805,7 @@
   "Return t if version V1 is equal to V2.
 
 Note that version string \"1\" is equal to \"1.0\", \"1.0.0\", \"1.0.0.0\",
-etc.  That is, the trailing \".0\"s are insignificant..  Also, version
+etc.  That is, the trailing \".0\"s are insignificant.  Also, version
 string \"1\" is higher (newer) than \"1pre\", which is higher than \"1beta\",
 which is higher than \"1alpha\"."
   (version-list-= (version-to-list v1) (version-to-list v2)))
--- a/lisp/term.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/term.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,8 @@
 ;;; term.el --- general command interpreter in a window stuff
 
-;; Copyright (C) 1988, 1990, 1992, 1994, 1995, 2001, 2002, 2003,
-;;   2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1988, 1990, 1992, 1994, 1995, 2001, 2002, 2003, 2004,
+;;   2005, 2006, 2007, 2008, 2009, 2010
+;;   Free Software Foundation, Inc.
 
 ;; Author: Per Bothner <per@bothner.com>
 ;; Maintainer: Dan Nicolaescu <dann@ics.uci.edu>, Per Bothner <per@bothner.com>
@@ -1798,15 +1799,11 @@
   "Expand directory stack reference before point.
 See `term-replace-by-expanded-history'.  Returns t if successful."
   (save-excursion
-    (let ((toend (- (save-excursion (end-of-line nil) (point)) (point)))
+    (let ((toend (- (line-end-position) (point)))
 	  (start (progn (term-bol nil) (point))))
       (while (progn
-	       (skip-chars-forward "^!^"
-				   (save-excursion
-				     (end-of-line nil) (- (point) toend)))
-	       (< (point)
-		  (save-excursion
-		    (end-of-line nil) (- (point) toend))))
+	       (skip-chars-forward "^!^" (- (line-end-position) toend))
+	       (< (point) (- (line-end-position) toend)))
 	;; This seems a bit complex.  We look for references such as !!, !-num,
 	;; !foo, !?foo, !{bar}, !?{bar}, ^oh, ^my^, ^god^it, ^never^ends^.
 	;; If that wasn't enough, the plings can be suffixed with argument
@@ -2112,7 +2109,7 @@
 (defun term-skip-prompt ()
   "Skip past the text matching regexp `term-prompt-regexp'.
 If this takes us past the end of the current line, don't skip at all."
-  (let ((eol (save-excursion (end-of-line) (point))))
+  (let ((eol (line-end-position)))
     (when (and (looking-at term-prompt-regexp)
 	       (<= (match-end 0) eol))
       (goto-char (match-end 0)))))
@@ -2471,11 +2468,10 @@
   "Return string around `point' that starts the current line or nil."
   (save-excursion
     (let* ((point (point))
-	   (bol (progn (beginning-of-line) (point)))
-	   (eol (progn (end-of-line) (point)))
-	   (start (progn (goto-char point)
-			 (and (search-backward "\"" bol t)
-			      (1+ (point)))))
+	   (bol (line-beginning-position))
+	   (eol (line-end-position))
+	   (start (and (search-backward "\"" bol t)
+                       (1+ (point))))
 	   (end (progn (goto-char point)
 		       (and (search-forward "\"" eol t)
 			    (1- (point))))))
@@ -4534,5 +4530,4 @@
 
 (provide 'term)
 
-;; arch-tag: eee16bc8-2cd7-4147-9534-a5694752f716
 ;;; term.el ends here
--- a/lisp/term/common-win.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/term/common-win.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/term/ns-win.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/term/pc-win.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/term/tty-colors.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/term/w32-win.el	Mon Nov 08 14:19:54 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/w32console.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/term/w32console.el	Mon Nov 08 14:19:54 2010 +0900
@@ -45,7 +45,7 @@
     ("white"         15 65535 65535 65535))
 "A list of VGA console colors, their indices and 16-bit RGB values.")
 
-(declare-function x-setup-function-keys "w32-fns" (frame))
+(declare-function x-setup-function-keys "term/common-win" (frame))
 
 (defun terminal-init-w32console ()
   "Terminal initialization function for w32 console."
@@ -62,4 +62,4 @@
   (tty-set-up-initial-frame-faces)
   (run-hooks 'terminal-init-w32-hook))
 
-;; arch-tag: 3195fd5e-ab86-4a46-b1dc-4f7a8c8deff3
+;;; w32console.el ends here
--- a/lisp/term/x-win.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/term/x-win.el	Mon Nov 08 14:19:54 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:
@@ -1351,6 +1279,13 @@
 (setq interprogram-cut-function 'x-select-text)
 (setq interprogram-paste-function 'x-selection-value)
 
+;; Make paste from other applications use the decoding in x-select-request-type
+;; and not just STRING.
+(defun x-get-selection-value ()
+  "Get the current value of the PRIMARY selection.
+Request data types in the order specified by `x-select-request-type'."
+  (x-selection-value-internal 'PRIMARY))
+
 (defun x-clipboard-yank ()
   "Insert the clipboard contents, or the last stretch of killed text."
   (interactive "*")
@@ -1640,5 +1575,4 @@
 
 (provide 'x-win)
 
-;; arch-tag: f1501302-db8b-4d95-88e3-116697d89f78
 ;;; x-win.el ends here
--- a/lisp/textmodes/bibtex.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/textmodes/bibtex.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,8 @@
 ;;; bibtex.el --- BibTeX mode for GNU Emacs
 
 ;; Copyright (C) 1992, 1994, 1995, 1996, 1997, 1998, 1999, 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.
 
 ;; Author: Stefan Schoef <schoef@offis.uni-oldenburg.de>
 ;;      Bengt Martensson <bengt@mathematik.uni-Bremen.de>
@@ -3835,16 +3836,16 @@
           (with-current-buffer (get-buffer-create err-buf)
             (setq default-directory dir)
             (unless (eq major-mode 'compilation-mode) (compilation-mode))
-            (toggle-read-only -1)
-            (delete-region (point-min) (point-max))
-            (insert "BibTeX mode command `bibtex-validate'\n"
-                    (if syntax-error
-                        "Maybe undetected errors due to syntax errors.  Correct and validate again.\n"
-                      "\n"))
-            (dolist (err error-list)
-              (insert (format "%s:%d: %s\n" file (car err) (cdr err))))
-            (set-buffer-modified-p nil)
-            (toggle-read-only 1)
+            (let ((inhibit-read-only t))
+              (delete-region (point-min) (point-max))
+              (insert "BibTeX mode command `bibtex-validate'\n"
+                      (if syntax-error
+                          "Maybe undetected errors due to syntax errors.  \
+Correct and validate again.\n"
+                        "\n"))
+              (dolist (err error-list)
+                (insert (format "%s:%d: %s\n" file (car err) (cdr err))))
+              (set-buffer-modified-p nil))
             (goto-char (point-min))
             (forward-line 2)) ; first error message
           (display-buffer err-buf)
@@ -3896,12 +3897,11 @@
         (let ((err-buf "*BibTeX validation errors*"))
           (with-current-buffer (get-buffer-create err-buf)
             (unless (eq major-mode 'compilation-mode) (compilation-mode))
-            (toggle-read-only -1)
-            (delete-region (point-min) (point-max))
-            (insert "BibTeX mode command `bibtex-validate-globally'\n\n")
-            (dolist (err (sort error-list 'string-lessp)) (insert err))
-            (set-buffer-modified-p nil)
-            (toggle-read-only 1)
+            (let ((inhibit-read-only t))
+              (delete-region (point-min) (point-max))
+              (insert "BibTeX mode command `bibtex-validate-globally'\n\n")
+              (dolist (err (sort error-list 'string-lessp)) (insert err))
+              (set-buffer-modified-p nil))
             (goto-char (point-min))
             (forward-line 2)) ; first error message
           (display-buffer err-buf)
@@ -4778,5 +4778,4 @@
 
 (provide 'bibtex)
 
-;; arch-tag: ee2be3af-caad-427f-b42a-d20fad630d04
 ;;; bibtex.el ends here
--- a/lisp/textmodes/flyspell.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/textmodes/flyspell.el	Mon Nov 08 14:19:54 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)))
 
@@ -1465,7 +1465,7 @@
       (goto-char (point-min))
       ;; Localwords parsing copied from ispell.el.
       (while (search-forward ispell-words-keyword nil t)
-	(let ((end (save-excursion (end-of-line) (point)))
+	(let ((end (point-at-eol))
 	      string)
 	  ;; buffer-local words separated by a space, and can contain
 	  ;; any character other than a space.  Not rigorous enough.
@@ -2354,5 +2354,4 @@
 
 (provide 'flyspell)
 
-;; arch-tag: 05d915b9-e9cf-44fb-9137-fc28f5eaab2a
 ;;; flyspell.el ends here
--- a/lisp/textmodes/ispell.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/textmodes/ispell.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,8 @@
 ;;; ispell.el --- interface to International Ispell Versions 3.1 and 3.2
 
 ;; Copyright (C) 1994, 1995, 1997, 1998, 1999, 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.
 
 ;; Author:           Ken Stevens <k.stevens@ieee.org>
 ;; Maintainer:       Ken Stevens <k.stevens@ieee.org>
@@ -983,19 +984,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 +1037,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.
@@ -2728,9 +2740,11 @@
 	(if extended-char-mode		; ~ extended character mode
 	    (ispell-send-string (concat extended-char-mode "\n"))))
       (if ispell-async-processp
-	  (if (fboundp 'set-process-query-on-exit-flag) ;; not XEmacs
+	  (if (featurep 'emacs)
 	      (set-process-query-on-exit-flag ispell-process nil)
-	    (process-kill-without-query ispell-process))))))
+	    (if (fboundp 'set-process-query-on-exit-flag)
+		(set-process-query-on-exit-flag ispell-process nil)
+	      (process-kill-without-query ispell-process)))))))
 
 ;;;###autoload
 (defun ispell-kill-ispell (&optional no-error)
@@ -3801,7 +3815,7 @@
     (goto-char (point-max))
     ;; Uses last occurrence of ispell-parsing-keyword
     (if (search-backward ispell-parsing-keyword nil t)
-	(let ((end (save-excursion (end-of-line) (point)))
+	(let ((end (point-at-eol))
 	      string)
 	  (search-forward ispell-parsing-keyword)
 	  (while (re-search-forward " *\\([^ \"]+\\)" end t)
@@ -3837,7 +3851,7 @@
 	(if (search-backward ispell-dictionary-keyword nil t)
 	    (progn
 	      (search-forward ispell-dictionary-keyword)
-	      (setq end (save-excursion (end-of-line) (point)))
+	      (setq end (point-at-eol))
 	      (if (re-search-forward " *\\([^ \"]+\\)" end t)
 		  (setq ispell-local-dictionary
 			(match-string-no-properties 1))))))
@@ -3845,7 +3859,7 @@
       (if (search-backward ispell-pdict-keyword nil t)
 	  (progn
 	    (search-forward ispell-pdict-keyword)
-	    (setq end (save-excursion (end-of-line) (point)))
+	    (setq end (point-at-eol))
 	    (if (re-search-forward " *\\([^ \"]+\\)" end t)
 		(setq ispell-local-pdict
 		      (match-string-no-properties 1)))))))
@@ -3869,7 +3883,7 @@
     (while (search-forward ispell-words-keyword nil t)
       (or ispell-buffer-local-name
 	  (setq ispell-buffer-local-name (buffer-name)))
-      (let ((end (save-excursion (end-of-line) (point)))
+      (let ((end (point-at-eol))
 	    (ispell-casechars (ispell-get-casechars))
 	    string)
 	;; buffer-local words separated by a space, and can contain
@@ -3885,6 +3899,9 @@
 
 ;;; returns optionally adjusted region-end-point.
 
+;; If comment-padright is defined, newcomment must be loaded.
+(declare-function comment-add "newcomment" (arg))
+
 (defun ispell-add-per-file-word-list (word)
   "Add WORD to the per-file word list."
   (or ispell-buffer-local-name
@@ -3959,5 +3976,4 @@
 ; LocalWords:  uuencoded unidiff sc nn VM SGML eval IspellPersDict unsplitable
 ; LocalWords:  lns XEmacs HTML casechars Multibyte
 
-;; arch-tag: 4941b9f9-3b7c-4a76-a4ed-5fa8b6010ef5
 ;;; ispell.el ends here
--- a/lisp/textmodes/page-ext.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/textmodes/page-ext.el	Mon Nov 08 14:19:54 2010 +0900
@@ -671,7 +671,7 @@
       (setq position (make-marker))
       (set-marker position (point))
       (let ((start (point))
-            (end (save-excursion (end-of-line) (point)))
+            (end (line-end-position))
 	    inserted-at)
         ;; change to directory buffer
         (set-buffer standard-output)
@@ -783,7 +783,7 @@
             (delete-other-windows))
         (save-excursion
           (goto-char (point-min))
-          (delete-region (point) (save-excursion (end-of-line) (point)))
+          (delete-region (point) (line-end-position))
           (insert
            "=== Address List Directory: use `C-c C-c' to go to page under cursor. ===")
           (set-buffer-modified-p nil)
@@ -801,5 +801,4 @@
 
 (provide 'page-ext)
 
-;; arch-tag: 2f311550-c6e0-4458-9c12-7f039c058bdb
 ;;; page-ext.el ends here
--- a/lisp/textmodes/picture.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/textmodes/picture.el	Mon Nov 08 14:19:54 2010 +0900
@@ -438,7 +438,7 @@
 	  (move-to-column target))
       (if (re-search-forward
 	   (concat "[ \t]+[" (regexp-quote picture-tab-chars) "]")
-	   (save-excursion (end-of-line) (point))
+	   (line-end-position)
 	   'move)
 	  (setq target (1- (current-column)))
 	(setq target nil)))
@@ -775,5 +775,4 @@
 
 (provide 'picture)
 
-;; arch-tag: e452d08d-a470-4fbf-896e-ea276698d1ca
 ;;; picture.el ends here
--- a/lisp/textmodes/reftex-cite.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/textmodes/reftex-cite.el	Mon Nov 08 14:19:54 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]*\
+\\(\\[[^]]*]\\)*\[ \t]*"))))))
+	      (goto-char end))))))
     (unless entries
       (error "No bibitems found"))
 
@@ -1144,9 +1147,8 @@
            (save-restriction
              (widen)
              (goto-char (point-min))
-             (while (re-search-forward
-                     "^[ \t]*@[a-zA-Z]+[ \t]*{\\([^ \t\r\n]+\\),"
-                     nil t)
+             (while (re-search-forward "^[ \t]*@\\(?:\\w\\|\\s_\\)+[ \t\n\r]*\
+\[{(][ \t\n\r]*\\([^ \t\n\r,]+\\)" nil t)
                (setq key (match-string 1)
                      beg (match-beginning 0)
                      end (progn
--- a/lisp/textmodes/reftex-index.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/textmodes/reftex-index.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1699,7 +1699,7 @@
           (let* ((lines (split-string (buffer-substring beg end) "\n"))
                  (lines1 (sort lines 'reftex-compare-phrase-lines)))
             (message "Sorting lines...done")
-            (let ((inhibit-quit t))  ;; make sure we do not loose lines
+            (let ((inhibit-quit t))  ;; make sure we do not lose lines
               (delete-region beg end)
               (insert (mapconcat 'identity lines1 "\n"))))
           (goto-char (point-max))
@@ -2104,5 +2104,4 @@
    ["Save and Return" reftex-index-phrases-save-and-return t]))
 
 
-;; arch-tag: 4b2362af-c156-42c1-8932-ea2823e205c1
 ;;; reftex-index.el ends here
--- a/lisp/textmodes/reftex-ref.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/textmodes/reftex-ref.el	Mon Nov 08 14:19:54 2010 +0900
@@ -180,8 +180,8 @@
                 (string-match "^[ \t]*$" default))
             (setq default prefix
                   force-prompt t)       ; need to prompt
-          (setq default 
-                (concat prefix 
+          (setq default
+                (concat prefix
                         (funcall reftex-string-to-label-function default)))
 
           ;; Make it unique.
@@ -227,7 +227,7 @@
              ((setq entry (assoc label
                                  (symbol-value reftex-docstruct-symbol)))
               (ding)
-              (if (y-or-n-p 
+              (if (y-or-n-p
                    (format "Label '%s' exists. Use anyway? " label))
                   (setq valid t)))
 
@@ -294,7 +294,7 @@
   ;; Translate the upper 128 chars in the Latin-1 charset to ASCII equivalents
   (let ((tab "@@@@@@@@@@@@@@@@@@'@@@@@@@@@@@@@ icLxY|S\"ca<--R-o|23'uq..1o>423?AAAAAAACEEEEIIIIDNOOOOOXOUUUUYP3aaaaaaaceeeeiiiidnooooo:ouuuuypy")
         (emacsp (not (featurep 'xemacs))))
-    (mapconcat 
+    (mapconcat
      (lambda (c)
        (cond ((and (> c 127) (< c 256))                 ; 8 bit Latin-1
               (char-to-string (aref tab (- c 128))))
@@ -430,7 +430,7 @@
               type (car type))
       (setq type (reftex-query-label-type))))
 
-  (let* ((refstyle 
+  (let* ((reftex-refstyle
           (cond ((reftex-typekey-check type reftex-vref-is-default) "\\vref")
                 ((reftex-typekey-check type reftex-fref-is-default) "\\fref")
                 (t "\\ref")))
@@ -452,7 +452,7 @@
     (setq type (nth 1 (car labels))
           form (or (cdr (assoc type reftex-typekey-to-format-alist))
                    form))
-    
+
     (cond
      (no-insert
       ;; Just return the first label
@@ -466,7 +466,7 @@
               sep (nth 2 (car labels))
               sep1 (cdr (assoc sep reftex-multiref-punctuation))
               labels (cdr labels))
-        (when cut 
+        (when cut
           (backward-delete-char cut)
           (setq cut nil))
 
@@ -477,9 +477,9 @@
         ;; do we have a special format?
         (setq reftex-format-ref-function
               (cond
-               ((string= refstyle "\\vref") 'reftex-format-vref)
-               ((string= refstyle "\\fref") 'reftex-format-fref)
-               ((string= refstyle "\\Fref") 'reftex-format-Fref)
+               ((string= reftex-refstyle "\\vref") 'reftex-format-vref)
+               ((string= reftex-refstyle "\\fref") 'reftex-format-fref)
+               ((string= reftex-refstyle "\\Fref") 'reftex-format-Fref)
                (t reftex-format-ref-function)))
         ;; ok, insert the reference
         (if sep1 (insert sep1))
@@ -501,7 +501,7 @@
         matched cell)
     (save-excursion
       (while (and (setq cell (pop words))
-                  (not (setq matched 
+                  (not (setq matched
                              (re-search-backward (car cell) bound t))))))
     (if matched
         (cons (cdr cell) (- (match-end 0) (match-end 1)))
@@ -549,7 +549,7 @@
               (setq mode-line-format
                     (list "----  " 'mode-line-buffer-identification
                           "  " 'global-mode-string "   (" mode-name ")"
-                          "  S<" 'refstyle ">"
+                          "  S<" 'reftex-refstyle ">"
                           " -%-"))
               (cond
                ((= 0 (buffer-size))
@@ -564,9 +564,9 @@
                                 context
                                 counter
                                 commented
-                                (or here-I-am offset) 
+                                (or here-I-am offset)
                                 prefix
-                                nil  ; no a toc buffer 
+                                nil  ; no a toc buffer
                                 ))))
                (here-I-am
                 (setq offset (reftex-get-offset buf here-I-am typekey)))
@@ -690,13 +690,13 @@
 
 (defun reftex-query-label-type ()
   ;; Ask for label type
-  (let ((key (reftex-select-with-char 
+  (let ((key (reftex-select-with-char
               reftex-type-query-prompt reftex-type-query-help 3)))
     (unless (member (char-to-string key) reftex-typekey-list)
       (error "No such label type: %s" (char-to-string key)))
     (char-to-string key)))
 
-(defun reftex-show-label-location (data forward no-revisit 
+(defun reftex-show-label-location (data forward no-revisit
                                         &optional stay error)
   ;; View the definition site of a label in another window.
   ;; DATA is an entry from the docstruct list.
@@ -718,7 +718,7 @@
         (throw 'exit nil))
 
       ;; Goto the file in another window
-      (setq buffer 
+      (setq buffer
             (if no-revisit
                 (reftex-get-buffer-visiting file)
               (reftex-get-file-buffer-force
@@ -784,7 +784,7 @@
             (when (or (not (eq major-mode 'latex-mode))
                       (not font-lock-mode))
               (latex-mode)
-              (run-hook-with-args 
+              (run-hook-with-args
                'reftex-pre-refontification-functions
                reftex-call-back-to-this-buffer 'reftex-hidden)
               (turn-on-font-lock))
@@ -839,10 +839,8 @@
     (unless other-window
       (set-window-configuration wcfg)
       (switch-to-buffer (marker-buffer where))
-      (goto-char where))      
+      (goto-char where))
     (reftex-unhighlight 0)))
 
 
-
-;; arch-tag: 52f14032-fb76-4d31-954f-750c72415675
 ;;; reftex-ref.el ends here
--- a/lisp/textmodes/reftex-sel.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/textmodes/reftex-sel.el	Mon Nov 08 14:19:54 2010 +0900
@@ -369,22 +369,21 @@
 (defvar reftex-last-line nil)
 (defvar reftex-select-marked nil)
 
-(defun reftex-select-item (prompt help-string keymap
+(defun reftex-select-item (reftex-select-prompt help-string keymap
                                   &optional offset
                                   call-back cb-flag)
-;; Select an item, using PROMPT. The function returns a key indicating
-;; an exit status, along with a data structure indicating which item was
-;; selected.
-;; HELP-STRING contains help.  KEYMAP is a keymap with the available
-;; selection commands.
-;; OFFSET can be a label list item which will be selected at start.
-;; When it is t, point will start out at the beginning of the buffer.
-;; Any other value will cause restart where last selection left off.
-;; When CALL-BACK is given, it is a function which is called with the index
-;; of the element.
-;; CB-FLAG is the initial value of that flag.
-
-  (let* (ev data last-data (selection-buffer (current-buffer)))
+  ;; Select an item, using REFTEX-SELECT-PROMPT.
+  ;; The function returns a key indicating an exit status, along with a
+  ;; data structure indicating which item was selected.
+  ;; HELP-STRING contains help.  KEYMAP is a keymap with the available
+  ;; selection commands.
+  ;; OFFSET can be a label list item which will be selected at start.
+  ;; When it is t, point will start out at the beginning of the buffer.
+  ;; Any other value will cause restart where last selection left off.
+  ;; When CALL-BACK is given, it is a function which is called with the index
+  ;; of the element.
+  ;; CB-FLAG is the initial value of that flag.
+  (let (ev reftex-select-data last-data (selection-buffer (current-buffer)))
 
     (setq reftex-select-marked nil)
 
@@ -404,7 +403,7 @@
             (use-local-map keymap)
             (add-hook 'pre-command-hook 'reftex-select-pre-command-hook nil t)
             (add-hook 'post-command-hook 'reftex-select-post-command-hook nil t)
-            (princ prompt)
+            (princ reftex-select-prompt)
             (set-marker reftex-recursive-edit-marker (point))
             ;; XEmacs does not run post-command-hook here
             (and (featurep 'xemacs) (run-hooks 'post-command-hook))
@@ -426,19 +425,18 @@
     (reftex-kill-buffer "*RefTeX Help*")
     (setq reftex-callback-fwd (not reftex-callback-fwd)) ;; ;-)))
     (message "")
-    (list ev data last-data)))
+    (list ev reftex-select-data last-data)))
 
 ;; The following variables are all bound dynamically in `reftex-select-item'.
 ;; The defvars are here only to silence the byte compiler.
 
 (defvar found-list)
 (defvar cb-flag)
-(defvar data)
-(defvar prompt)
+(defvar reftex-select-data)
+(defvar reftex-select-prompt)
 (defvar last-data)
 (defvar call-back)
 (defvar help-string)
-(defvar refstyle)
 
 ;; The selection commands
 
@@ -448,15 +446,15 @@
 
 (defun reftex-select-post-command-hook ()
   (let (b e)
-    (setq data (get-text-property (point) :data))
-    (setq last-data (or data last-data))
+    (setq reftex-select-data (get-text-property (point) :data))
+    (setq last-data (or reftex-select-data last-data))
 
-    (when (and data cb-flag
+    (when (and reftex-select-data cb-flag
                (not (equal reftex-last-follow-point (point))))
       (setq reftex-last-follow-point (point))
-      (funcall call-back data reftex-callback-fwd
+      (funcall call-back reftex-select-data reftex-callback-fwd
                (not reftex-revisit-to-follow)))
-    (if data
+    (if reftex-select-data
         (setq b (or (previous-single-property-change
                      (1+ (point)) :data)
                     (point-min))
@@ -470,7 +468,7 @@
             (not (pos-visible-in-window-p e)))
         (recenter '(4)))
     (unless (current-message)
-      (princ prompt))))
+      (princ reftex-select-prompt))))
 
 (defun reftex-select-next (&optional arg)
   "Move to next selectable item."
@@ -531,19 +529,22 @@
   (interactive)
   (setq reftex-last-follow-point -1)
   (setq cb-flag (not cb-flag)))
+
+(defvar reftex-refstyle)                ; from reftex-reference
+
 (defun reftex-select-toggle-varioref ()
   "Toggle the macro used for referencing the label between \\ref and \\vref."
   (interactive)
-  (if (string= refstyle "\\ref")
-      (setq refstyle "\\vref")
-    (setq refstyle "\\ref"))
+  (if (string= reftex-refstyle "\\ref")
+      (setq reftex-refstyle "\\vref")
+    (setq reftex-refstyle "\\ref"))
   (force-mode-line-update))
 (defun reftex-select-toggle-fancyref ()
   "Toggle the macro used for referencing the label between \\ref and \\vref."
   (interactive)
-  (setq refstyle
-        (cond ((string= refstyle "\\ref") "\\fref")
-              ((string= refstyle "\\fref") "\\Fref")
+  (setq reftex-refstyle
+        (cond ((string= reftex-refstyle "\\ref") "\\fref")
+              ((string= reftex-refstyle "\\fref") "\\Fref")
               (t "\\ref")))
   (force-mode-line-update))
 (defun reftex-select-show-insertion-point ()
@@ -560,7 +561,7 @@
 (defun reftex-select-callback ()
   "Show full context in another window."
   (interactive)
-  (if data (funcall call-back data reftex-callback-fwd nil) (ding)))
+  (if reftex-select-data (funcall call-back reftex-select-data reftex-callback-fwd nil) (ding)))
 (defun reftex-select-accept ()
   "Accept the currently selected item."
   (interactive)
@@ -569,8 +570,8 @@
   "Accept the item at the mouse click."
   (interactive "e")
   (mouse-set-point ev)
-  (setq data (get-text-property (point) :data))
-  (setq last-data (or data last-data))
+  (setq reftex-select-data (get-text-property (point) :data))
+  (setq last-data (or reftex-select-data last-data))
   (throw 'myexit 'return))
 (defun reftex-select-read-label ()
   "Use minibuffer to read a label to reference, with completion."
@@ -588,8 +589,8 @@
     (cond
      ((or (null key) (equal key "")))
      (entry
-      (setq data entry)
-      (setq last-data data)
+      (setq reftex-select-data entry)
+      (setq last-data reftex-select-data)
       (throw 'myexit 'return))
      (t (throw 'myexit key)))))
 
@@ -736,5 +737,4 @@
       do (define-key reftex-select-bib-map (car x) (cdr x)))
 
 
-;; arch-tag: 842078ff-0586-4e0b-957e-536e08218464
 ;;; reftex-sel.el ends here
--- a/lisp/textmodes/reftex-toc.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/textmodes/reftex-toc.el	Mon Nov 08 14:19:54 2010 +0900
@@ -545,8 +545,6 @@
 
 ;; Promotion/Demotion stuff
 
-(defvar delta)
-(defvar mpos)
 (defvar pro-or-de)
 (defvar start-pos)
 (defvar start-line)
@@ -575,7 +573,7 @@
 					    (if (bolp) 1 0)))))
          (start-pos (point))
          (pro-or-de (if (> delta 0) "de" "pro"))
-         beg end entries data sections nsec mpos msg)
+         beg end entries data sections nsec msg)
     (setq msg
           (catch 'exit
             (if (reftex-region-active-p)
@@ -602,7 +600,9 @@
                               (reftex-toc-extract-section-number
                                (nth (1- nsec) entries)))))
             ;; Run through the list and prepare the changes.
-            (setq entries (mapcar 'reftex-toc-promote-prepare entries))
+            (setq entries (mapcar
+                           (lambda (e) (reftex-toc-promote-prepare e delta))
+                           entries))
             ;; Ask for permission
             (if (or (not reftex-toc-confirm-promotion)           ; never confirm
                     (and (integerp reftex-toc-confirm-promotion) ; confirm if many
@@ -629,31 +629,26 @@
 
 
 (defun reftex-toc-restore-region (point-line &optional mark-line)
-  (when mark-line
-    (goto-char (point-min))
-    (forward-line (1- mark-line))
-    (setq mpos (point)))
-  (when point-line
-    (goto-char (point-min))
-    (forward-line (1- point-line)))
-  (if mark-line
-      (progn
-        (set-mark mpos)
-        (if (featurep 'xemacs)
-            (zmacs-activate-region)
-          (setq mark-active t
-                deactivate-mark nil)))))
+  (let (mpos)
+    (when mark-line
+      (goto-char (point-min))
+      (forward-line (1- mark-line))
+      (setq mpos (point)))
+    (when point-line
+      (goto-char (point-min))
+      (forward-line (1- point-line)))
+    (when mark-line
+      (set-mark mpos)
+      (if (featurep 'xemacs)
+          (zmacs-activate-region)
+        (setq mark-active t
+              deactivate-mark nil)))))
 
-(defvar name1)
-(defvar dummy)
-(defvar dummy2)
-
-(defun reftex-toc-promote-prepare (x)
+(defun reftex-toc-promote-prepare (x delta)
   "Look at a toc entry and see if we could pro/demote it.
-Expects the level change DELTA to be dynamically scoped into this function.
 This function prepares everything for the changes, but does not do it.
 The return value is a list with information needed when doing the
-promotion/demotion later."
+promotion/demotion later.  DELTA is the level change."
   (let* ((data (car x))
          (toc-point (cdr x))
          (marker (nth 4 data))
@@ -678,7 +673,7 @@
                           (error "Something is wrong!  Contact maintainer!")))
                     ;; Section has changed, request scan and loading
                     ;; We use a variable to delay until after the safe-exc.
-                    ;; because otherwise we loose the region.
+                    ;; because otherwise we lose the region.
                     (setq load t)))
                 ;; Scan document and load all files, this exits command
                 (if load (reftex-toc-load-all-files-for-promotion))) ; exits
@@ -689,7 +684,6 @@
                     (progn
                       (goto-char toc-point)
                       (error "Cannot %smote special sections" pro-or-de))))
-         ;; Delta is dynamically scoped into here...
          (newlevel (if (>= level 0) (+ delta level) (- level delta)))
          (dummy2 (if (or (and (>= level 0) (= newlevel -1))
                          (and (< level 0)  (= newlevel 0)))
@@ -703,7 +697,7 @@
 
 (defun reftex-toc-promote-action (x)
   "Change the level of a toc entry.
-DELTA and PRO-OR-DE are assumed to be dynamically scoped into this function."
+PRO-OR-DE is assumed to be dynamically scoped into this function."
   (let* ((data (car x))
          (name (nth 1 x))
          (newname (nth 2 x))
@@ -1100,5 +1094,4 @@
    ["Help" reftex-toc-show-help t]))
 
 
-;; arch-tag: 92400ce2-0b86-4c89-a606-4ed71acea17e
 ;;; reftex-toc.el ends here
--- a/lisp/textmodes/sgml-mode.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/textmodes/sgml-mode.el	Mon Nov 08 14:19:54 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/table.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/textmodes/table.el	Mon Nov 08 14:19:54 2010 +0900
@@ -5057,7 +5057,7 @@
 	  (intersection-str (regexp-quote (char-to-string table-cell-intersection-char)))
 	  (v-border (format "[%c%c]" table-cell-vertical-char table-cell-intersection-char))
 	  (h-border (format "[%s%c]" table-cell-horizontal-chars table-cell-intersection-char))
-	  (limit (save-excursion (beginning-of-line) (point))))
+	  (limit (line-beginning-position)))
       (catch 'end
 	(while t
 	  (catch 'retry-horizontal
@@ -5095,7 +5095,7 @@
 	  (intersection-str (regexp-quote (char-to-string table-cell-intersection-char)))
 	  (v-border (format "[%c%c]" table-cell-vertical-char table-cell-intersection-char))
 	  (h-border (format "[%s%c]" table-cell-horizontal-chars table-cell-intersection-char))
-	  (limit (save-excursion (end-of-line) (point))))
+	  (limit (line-end-position)))
       (catch 'end
 	(while t
 	  (catch 'retry-horizontal
@@ -5589,5 +5589,4 @@
 
 (provide 'table)
 
-;; arch-tag: 0d69b03e-aa5f-4e72-8806-5727217617e0
 ;;; table.el ends here
--- a/lisp/textmodes/tex-mode.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/textmodes/tex-mode.el	Mon Nov 08 14:19:54 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/textmodes/texnfo-upd.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/textmodes/texnfo-upd.el	Mon Nov 08 14:19:54 2010 +0900
@@ -719,21 +719,21 @@
   (let (beginning end node-name title)
     (save-excursion
       (beginning-of-line)
-      (if (search-forward "* " (save-excursion (end-of-line) (point)) t)
+      (if (search-forward "* " (line-end-position) t)
 	  (progn (skip-chars-forward " \t")
 		 (setq beginning (point)))
 	(error "This is not a line in a menu"))
 
       (cond
        ;; "Double colon" entry line; menu entry and node name are the same,
-       ((search-forward "::" (save-excursion (end-of-line) (point)) t)
+       ((search-forward "::" (line-end-position) t)
 	(if (looking-at "[ \t]*[^ \t\n]+")
 	    (error "Descriptive text already exists"))
 	(skip-chars-backward ": \t")
 	(setq node-name (buffer-substring beginning (point))))
 
        ;; "Single colon" entry line; menu entry and node name are different.
-       ((search-forward ":" (save-excursion (end-of-line) (point)) t)
+       ((search-forward ":" (line-end-position) t)
 	(skip-chars-forward " \t")
 	(setq beginning (point))
 	;; Menu entry line ends in a period, comma, or tab.
@@ -1154,8 +1154,7 @@
       (save-excursion
 	(goto-char (point-min))
 	(re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" nil t)
-	(beginning-of-line)
-	(point)))
+	(line-beginning-position)))
      (t
       (save-excursion
 	(re-search-backward
@@ -1206,13 +1205,11 @@
 First argument is the position of the beginning of the section in
 which the menu will be located; second argument is the position of the
 end of that region; it limits the search."
-
   (save-excursion
     (goto-char beginning)
     (forward-line 1)
     (re-search-forward "^@node" end t)
-    (beginning-of-line)
-    (point)))
+    (line-beginning-position)))
 
 
 ;;; Updating a node
@@ -1331,7 +1328,7 @@
 Starts from the current position of the cursor, and searches forward
 on the line for a comma and if one is found, deletes the rest of the
 line, including the comma.  Leaves point at beginning of line."
-  (let ((eol-point (save-excursion (end-of-line) (point))))
+  (let ((eol-point (line-end-position)))
     (if (search-forward "," eol-point t)
 	(delete-region (1- (point)) eol-point)))
   (beginning-of-line))
@@ -1437,8 +1434,7 @@
 		 "\\)")
 		(save-excursion
 		  (goto-char beginning)
-		  (beginning-of-line)
-		  (point))
+		  (line-beginning-position))
 		t)
 	       'normal
 	     'no-pointer))
@@ -1483,7 +1479,7 @@
   "Remove extra commas, if any, at end of node line."
   (end-of-line)
   (skip-chars-backward ", ")
-  (delete-region (point) (save-excursion (end-of-line) (point))))
+  (delete-region (point) (line-end-position)))
 
 
 ;;; Updating nodes sequentially
@@ -1647,7 +1643,7 @@
 	    (skip-chars-forward " \t")
 	    (setq title (buffer-substring
 			 (point)
-			 (save-excursion (end-of-line) (point))))))
+			 (line-end-position)))))
       ;; Insert node line if necessary.
       (if (re-search-backward
 	   "^@node"
@@ -1993,9 +1989,7 @@
 	 (point-min)
 	 (save-excursion
 	   (re-search-forward "^@include")
-	   (beginning-of-line)
-	   (point)))
-
+	   (line-beginning-position)))
 	;; If found, leave point after word `menu' on the `@menu' line.
 	(progn
 	  (texinfo-incorporate-descriptions main-menu-list)
@@ -2057,5 +2051,4 @@
 ;; Place `provide' at end of file.
 (provide 'texnfo-upd)
 
-;; arch-tag: d21613a5-c32f-43f4-8af4-bfb1e7455842
 ;;; texnfo-upd.el ends here
--- a/lisp/tool-bar.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/tool-bar.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,8 +1,8 @@
 ;;; tool-bar.el --- setting up the tool bar
-;;
-;; Copyright (C) 2000, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
-;;
+
+;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+;;   2009, 2010  Free Software Foundation, Inc.
+
 ;; Author: Dave Love <fx@gnu.org>
 ;; Keywords: mouse frames
 ;; Package: emacs
@@ -51,8 +51,8 @@
 conveniently adding tool bar items."
   :init-value t
   :global t
-  :group 'mouse
-  :group 'frames
+  ;; It's defined in C/cus-start, this stops the d-m-m macro defining it again.
+  :variable tool-bar-mode
   (let ((val (if tool-bar-mode 1 0)))
     (dolist (frame (frame-list))
       (set-frame-parameter frame 'tool-bar-lines val))
@@ -325,10 +325,10 @@
       :initialize 'custom-initialize-default
       :set (lambda (sym val)
 	     (set-default sym val)
-	     (modify-all-frames-parameters 
+	     (modify-all-frames-parameters
 	      (list (cons 'tool-bar-position val))))))
 
 
 (provide 'tool-bar)
-;; arch-tag: 15f30f0a-d0d7-4d50-bbb7-f48fd0c8582f
+
 ;;; tool-bar.el ends here
--- a/lisp/type-break.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/type-break.el	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,7 @@
 ;;; type-break.el --- encourage rests from typing at appropriate intervals
 
-;; Copyright (C) 1994, 1995, 1997, 2000, 2001, 2002, 2003,
-;;   2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 1995, 1997, 2000, 2001, 2002, 2003, 2004, 2005,
+;;   2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: Noah Friedman
 ;; Maintainer: Noah Friedman <friedman@splode.com>
@@ -495,7 +495,7 @@
 	    (let ((inhibit-read-only t))
 	      (goto-char (point-min))
 	      (forward-line)
-	      (delete-region (point) (save-excursion (end-of-line) (point)))
+	      (delete-region (point) (line-end-position))
 	      (insert (format "%s" type-break-keystroke-count))
 	      ;; file saving is left to auto-save
 	      ))))))
@@ -1243,5 +1243,4 @@
 (if type-break-mode
     (type-break-mode 1))
 
-;; arch-tag: 943a2eb3-07e6-420b-993f-96e4796f5fd0
 ;;; type-break.el ends here
--- a/lisp/url/ChangeLog	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/url/ChangeLog	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/url/url-gw.el	Mon Nov 08 14:19:54 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/add-log.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/vc/add-log.el	Mon Nov 08 14:19:54 2010 +0900
@@ -698,7 +698,7 @@
 Optional arg BUFFER-FILE overrides `buffer-file-name'."
   ;; If we are called from a diff, first switch to the source buffer;
   ;; in order to respect buffer-local settings of change-log-default-name, etc.
-  (with-current-buffer (let ((buff (if (eq major-mode 'diff-mode)
+  (with-current-buffer (let ((buff (if (derived-mode-p 'diff-mode)
 				       (car (ignore-errors
 					     (diff-find-source-location))))))
 			 (if (buffer-live-p buff) buff
@@ -1180,7 +1180,7 @@
 		((apply 'derived-mode-p add-log-c-like-modes)
 		 (or (c-cpp-define-name)
 		     (c-defun-name)))
-		((memq major-mode add-log-tex-like-modes)
+		((apply #'derived-mode-p add-log-tex-like-modes)
 		 (if (re-search-backward
 		      "\\\\\\(sub\\)*\\(section\\|paragraph\\|chapter\\)"
 		      nil t)
--- a/lisp/vc/ediff-util.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/vc/ediff-util.el	Mon Nov 08 14:19:54 2010 +0900
@@ -311,7 +311,7 @@
 	    ediff-word-mode-job (ediff-word-mode-job))
 
       ;; Don't delete variants in case of ediff-buffer-* jobs without asking.
-      ;; This is because one may loose work---dangerous.
+      ;; This is because one may lose work---dangerous.
       (if (string-match "buffer" (symbol-name ediff-job-name))
 	  (setq ediff-keep-variants t))
 
@@ -4289,5 +4289,4 @@
 ;; eval: (put 'ediff-with-current-buffer 'edebug-form-spec '(form body))
 ;; End:
 
-;; arch-tag: f51099b6-ef4b-470f-88a1-3a0e0b03a879
 ;;; ediff-util.el ends here
--- a/lisp/vc/emerge.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/vc/emerge.el	Mon Nov 08 14:19:54 2010 +0900
@@ -29,25 +29,13 @@
 (defvar A-end)
 (defvar B-begin)
 (defvar B-end)
-(defvar diff)
 (defvar diff-vector)
 (defvar merge-begin)
 (defvar merge-end)
-(defvar template)
 (defvar valid-diff)
 
 ;;; Macros
 
-(defmacro emerge-eval-in-buffer (buffer &rest forms)
-  "Macro to switch to BUFFER, evaluate FORMS, returns to original buffer.
-Differs from `save-excursion' in that it doesn't save the point and mark."
-  `(let ((StartBuffer (current-buffer)))
-    (unwind-protect
-         (progn
-           (set-buffer ,buffer)
-           ,@forms)
-      (set-buffer StartBuffer))))
-
 (defmacro emerge-defvar-local (var value doc)
   "Defines SYMBOL as an advertised variable.
 Performs a defvar, then executes `make-variable-buffer-local' on
@@ -565,7 +553,7 @@
     (if output-file
 	(setq emerge-last-dir-output (file-name-directory output-file)))
     ;; Make sure the entire files are seen, and they reflect what is on disk
-    (emerge-eval-in-buffer
+    (with-current-buffer
      buffer-A
      (widen)
      (let ((temp (file-local-copy file-A)))
@@ -576,7 +564,7 @@
 		       startup-hooks))
            ;; Verify that the file matches the buffer
            (emerge-verify-file-buffer))))
-    (emerge-eval-in-buffer
+    (with-current-buffer
      buffer-B
      (widen)
      (let ((temp (file-local-copy file-B)))
@@ -599,10 +587,10 @@
   (let* ((merge-buffer-name (emerge-unique-buffer-name "*merge" "*"))
 	 ;; create the merge buffer from buffer A, so it inherits buffer A's
 	 ;; default directory, etc.
-	 (merge-buffer (emerge-eval-in-buffer
+	 (merge-buffer (with-current-buffer
 			buffer-A
 			(get-buffer-create merge-buffer-name))))
-    (emerge-eval-in-buffer
+    (with-current-buffer
      merge-buffer
      (emerge-copy-modes buffer-A)
      (setq buffer-read-only nil)
@@ -625,14 +613,14 @@
      (emerge-remember-buffer-characteristics)
      (emerge-handle-local-variables))
     (emerge-setup-windows buffer-A buffer-B merge-buffer t)
-    (emerge-eval-in-buffer merge-buffer
+    (with-current-buffer merge-buffer
 			   (run-hooks 'startup-hooks 'emerge-startup-hook)
 			   (setq buffer-read-only t))))
 
 ;; Generate the Emerge difference list between two files
 (defun emerge-make-diff-list (file-A file-B)
   (setq emerge-diff-buffer (get-buffer-create "*emerge-diff*"))
-  (emerge-eval-in-buffer
+  (with-current-buffer
    emerge-diff-buffer
    (erase-buffer)
    (shell-command
@@ -648,7 +636,7 @@
 
 (defun emerge-extract-diffs (diff-buffer)
   (let (list)
-    (emerge-eval-in-buffer
+    (with-current-buffer
      diff-buffer
      (goto-char (point-min))
      (while (re-search-forward emerge-match-diff-line nil t)
@@ -692,7 +680,7 @@
 ;; Set up buffer of diff/diff3 error messages.
 (defun emerge-prepare-error-list (ok-regexp)
   (setq emerge-diff-error-buffer (get-buffer-create "*emerge-diff-errors*"))
-  (emerge-eval-in-buffer
+  (with-current-buffer
    emerge-diff-error-buffer
    (erase-buffer)
    (save-excursion (insert-buffer-substring emerge-diff-buffer))
@@ -719,7 +707,7 @@
     (if output-file
 	(setq emerge-last-dir-output (file-name-directory output-file)))
     ;; Make sure the entire files are seen, and they reflect what is on disk
-    (emerge-eval-in-buffer
+    (with-current-buffer
      buffer-A
      (widen)
      (let ((temp (file-local-copy file-A)))
@@ -730,7 +718,7 @@
 		       startup-hooks))
            ;; Verify that the file matches the buffer
            (emerge-verify-file-buffer))))
-    (emerge-eval-in-buffer
+    (with-current-buffer
      buffer-B
      (widen)
      (let ((temp (file-local-copy file-B)))
@@ -741,7 +729,7 @@
 		       startup-hooks))
            ;; Verify that the file matches the buffer
            (emerge-verify-file-buffer))))
-    (emerge-eval-in-buffer
+    (with-current-buffer
      buffer-ancestor
      (widen)
      (let ((temp (file-local-copy file-ancestor)))
@@ -768,10 +756,10 @@
   (let* ((merge-buffer-name (emerge-unique-buffer-name "*merge" "*"))
 	 ;; create the merge buffer from buffer A, so it inherits buffer A's
 	 ;; default directory, etc.
-	 (merge-buffer (emerge-eval-in-buffer
+	 (merge-buffer (with-current-buffer
 			buffer-A
 			(get-buffer-create merge-buffer-name))))
-    (emerge-eval-in-buffer
+    (with-current-buffer
      merge-buffer
      (emerge-copy-modes buffer-A)
      (setq buffer-read-only nil)
@@ -796,14 +784,14 @@
      (emerge-select-prefer-Bs)
      (emerge-handle-local-variables))
     (emerge-setup-windows buffer-A buffer-B merge-buffer t)
-    (emerge-eval-in-buffer merge-buffer
+    (with-current-buffer merge-buffer
 			   (run-hooks 'startup-hooks 'emerge-startup-hook)
 			   (setq buffer-read-only t))))
 
 ;; Generate the Emerge difference list between two files with an ancestor
 (defun emerge-make-diff3-list (file-A file-B file-ancestor)
   (setq emerge-diff-buffer (get-buffer-create "*emerge-diff*"))
-  (emerge-eval-in-buffer
+  (with-current-buffer
    emerge-diff-buffer
    (erase-buffer)
    (shell-command
@@ -820,7 +808,7 @@
 
 (defun emerge-extract-diffs3 (diff-buffer)
   (let (list)
-    (emerge-eval-in-buffer
+    (with-current-buffer
      diff-buffer
      (while (re-search-forward "^====\\(.?\\)$" nil t)
        ;; leave point after matched line
@@ -928,10 +916,10 @@
   (interactive "bBuffer A to merge: \nbBuffer B to merge: ")
   (let ((emerge-file-A (emerge-make-temp-file "A"))
 	(emerge-file-B (emerge-make-temp-file "B")))
-    (emerge-eval-in-buffer
+    (with-current-buffer
      buffer-A
      (write-region (point-min) (point-max) emerge-file-A nil 'no-message))
-    (emerge-eval-in-buffer
+    (with-current-buffer
      buffer-B
      (write-region (point-min) (point-max) emerge-file-B nil 'no-message))
     (emerge-setup (get-buffer buffer-A) emerge-file-A
@@ -953,13 +941,13 @@
   (let ((emerge-file-A (emerge-make-temp-file "A"))
 	(emerge-file-B (emerge-make-temp-file "B"))
 	(emerge-file-ancestor (emerge-make-temp-file "anc")))
-    (emerge-eval-in-buffer
+    (with-current-buffer
      buffer-A
      (write-region (point-min) (point-max) emerge-file-A nil 'no-message))
-    (emerge-eval-in-buffer
+    (with-current-buffer
      buffer-B
      (write-region (point-min) (point-max) emerge-file-B nil 'no-message))
-    (emerge-eval-in-buffer
+    (with-current-buffer
      buffer-ancestor
      (write-region (point-min) (point-max) emerge-file-ancestor nil
 		   'no-message))
@@ -1093,7 +1081,7 @@
 	(emerge-file-A (emerge-make-temp-file "A"))
 	(emerge-file-B (emerge-make-temp-file "B")))
     ;; Get the revisions into buffers
-    (emerge-eval-in-buffer
+    (with-current-buffer
      buffer-A
      (erase-buffer)
      (shell-command
@@ -1101,7 +1089,7 @@
       t)
      (write-region (point-min) (point-max) emerge-file-A nil 'no-message)
      (set-buffer-modified-p nil))
-    (emerge-eval-in-buffer
+    (with-current-buffer
      buffer-B
      (erase-buffer)
      (shell-command
@@ -1131,7 +1119,7 @@
 	(emerge-file-B (emerge-make-temp-file "B"))
 	(emerge-ancestor (emerge-make-temp-file "ancestor")))
     ;; Get the revisions into buffers
-    (emerge-eval-in-buffer
+    (with-current-buffer
      buffer-A
      (erase-buffer)
      (shell-command
@@ -1140,7 +1128,7 @@
       t)
      (write-region (point-min) (point-max) emerge-file-A nil 'no-message)
      (set-buffer-modified-p nil))
-    (emerge-eval-in-buffer
+    (with-current-buffer
      buffer-B
      (erase-buffer)
      (shell-command
@@ -1148,7 +1136,7 @@
       t)
      (write-region (point-min) (point-max) emerge-file-B nil 'no-message)
      (set-buffer-modified-p nil))
-    (emerge-eval-in-buffer
+    (with-current-buffer
      buffer-ancestor
      (erase-buffer)
      (shell-command
@@ -1379,7 +1367,7 @@
   (if pos
       (goto-char (point-min)))
   ;; If diff/diff3 reports errors, display them rather than the merge buffer.
-  (if (/= 0 (emerge-eval-in-buffer emerge-diff-error-buffer (buffer-size)))
+  (if (/= 0 (with-current-buffer emerge-diff-error-buffer (buffer-size)))
       (progn
 	(ding)
 	(message "Errors found in diff/diff3 output.  Merge buffer is %s."
@@ -1434,14 +1422,14 @@
   (do-auto-save)
   ;; remember and alter buffer characteristics
   (setq emerge-A-buffer-values
-	(emerge-eval-in-buffer
+	(with-current-buffer
 	 emerge-A-buffer
 	 (prog1
 	     (emerge-save-variables emerge-saved-variables)
 	   (emerge-restore-variables emerge-saved-variables
 				     emerge-merging-values))))
   (setq emerge-B-buffer-values
-	(emerge-eval-in-buffer
+	(with-current-buffer
 	 emerge-B-buffer
 	 (prog1
 	     (emerge-save-variables emerge-saved-variables)
@@ -1452,10 +1440,10 @@
   "Restore characteristics saved by `emerge-remember-buffer-characteristics'."
   (let ((A-values emerge-A-buffer-values)
 	(B-values emerge-B-buffer-values))
-    (emerge-eval-in-buffer emerge-A-buffer
+    (with-current-buffer emerge-A-buffer
 			   (emerge-restore-variables emerge-saved-variables
 						     A-values))
-    (emerge-eval-in-buffer emerge-B-buffer
+    (with-current-buffer emerge-B-buffer
 			   (emerge-restore-variables emerge-saved-variables
 						     B-values))))
 
@@ -1470,15 +1458,15 @@
 					merge-buffer
 					lineno-list)
   (let* (marker-list
-	 (A-point-min (emerge-eval-in-buffer A-buffer (point-min)))
+	 (A-point-min (with-current-buffer A-buffer (point-min)))
 	 (offset (1- A-point-min))
-	 (B-point-min (emerge-eval-in-buffer B-buffer (point-min)))
+	 (B-point-min (with-current-buffer B-buffer (point-min)))
 	 ;; Record current line number in each buffer
 	 ;; so we don't have to count from the beginning.
 	 (a-line 1)
 	 (b-line 1))
-    (emerge-eval-in-buffer A-buffer (goto-char (point-min)))
-    (emerge-eval-in-buffer B-buffer (goto-char (point-min)))
+    (with-current-buffer A-buffer (goto-char (point-min)))
+    (with-current-buffer B-buffer (goto-char (point-min)))
     (while lineno-list
       (let* ((list-element (car lineno-list))
 	     a-begin-marker
@@ -1493,13 +1481,13 @@
 	     (b-end (aref list-element 3))
 	     (state (aref list-element 4)))
 	;; place markers at the appropriate places in the buffers
-	(emerge-eval-in-buffer
+	(with-current-buffer
 	 A-buffer
 	 (setq a-line (emerge-goto-line a-begin a-line))
 	 (setq a-begin-marker (point-marker))
 	 (setq a-line (emerge-goto-line a-end a-line))
 	 (setq a-end-marker (point-marker)))
-	(emerge-eval-in-buffer
+	(with-current-buffer
 	 B-buffer
 	 (setq b-line (emerge-goto-line b-begin b-line))
 	 (setq b-begin-marker (point-marker))
@@ -1759,7 +1747,7 @@
 to the left margin, if they are in windows."
   (interactive)
   (emerge-operate-on-windows
-   (function (lambda (x) (set-window-hscroll (selected-window) 0)))
+   (lambda (x) (set-window-hscroll (selected-window) 0))
    nil))
 
 ;; Attempt to show the region nicely.
@@ -1869,13 +1857,13 @@
   (emerge-restore-buffer-characteristics)
   ;; null out the difference markers so they don't slow down future editing
   ;; operations
-  (mapc (function (lambda (d)
-		    (set-marker (aref d 0) nil)
-		    (set-marker (aref d 1) nil)
-		    (set-marker (aref d 2) nil)
-		    (set-marker (aref d 3) nil)
-		    (set-marker (aref d 4) nil)
-		    (set-marker (aref d 5) nil)))
+  (mapc (lambda (d)
+	  (set-marker (aref d 0) nil)
+	  (set-marker (aref d 1) nil)
+	  (set-marker (aref d 2) nil)
+	  (set-marker (aref d 3) nil)
+	  (set-marker (aref d 4) nil)
+	  (set-marker (aref d 5) nil))
 	  emerge-difference-list)
   ;; allow them to be garbage collected
   (setq emerge-difference-list nil)
@@ -1900,19 +1888,18 @@
 even if the difference has been edited."
   (interactive "P")
   (let ((operate
-	 (function (lambda ()
-		     (emerge-select-A-edit merge-begin merge-end A-begin A-end)
-		     (if emerge-auto-advance
-			 (emerge-next-difference)))))
+	 (lambda ()
+	   (emerge-select-A-edit merge-begin merge-end A-begin A-end)
+	   (if emerge-auto-advance
+	       (emerge-next-difference))))
 	(operate-no-change
-	 (function (lambda ()
-		     (if emerge-auto-advance
-			 (emerge-next-difference))))))
+	 (lambda () (if emerge-auto-advance
+			(emerge-next-difference)))))
     (emerge-select-version force operate-no-change operate operate)))
 
 ;; Actually select the A variant
 (defun emerge-select-A-edit (merge-begin merge-end A-begin A-end)
-  (emerge-eval-in-buffer
+  (with-current-buffer
    emerge-merge-buffer
    (delete-region merge-begin merge-end)
    (goto-char merge-begin)
@@ -1929,19 +1916,18 @@
 even if the difference has been edited."
   (interactive "P")
   (let ((operate
-	 (function (lambda ()
-		     (emerge-select-B-edit merge-begin merge-end B-begin B-end)
-		     (if emerge-auto-advance
-			 (emerge-next-difference)))))
+	 (lambda ()
+	   (emerge-select-B-edit merge-begin merge-end B-begin B-end)
+	   (if emerge-auto-advance
+	       (emerge-next-difference))))
 	(operate-no-change
-	 (function (lambda ()
-		     (if emerge-auto-advance
-			 (emerge-next-difference))))))
+	 (lambda () (if emerge-auto-advance
+			(emerge-next-difference)))))
     (emerge-select-version force operate operate-no-change operate)))
 
 ;; Actually select the B variant
 (defun emerge-select-B-edit (merge-begin merge-end B-begin B-end)
-  (emerge-eval-in-buffer
+  (with-current-buffer
    emerge-merge-buffer
    (delete-region merge-begin merge-end)
    (goto-char merge-begin)
@@ -2134,12 +2120,12 @@
   (interactive)
   (delete-other-windows)
   (let ((temp-buffer-show-function
-	 (function (lambda (buf)
-		     (split-window-vertically)
-		     (switch-to-buffer buf)
-		     (other-window 1)))))
+	 (lambda (buf)
+	   (split-window-vertically)
+	   (switch-to-buffer buf)
+	   (other-window 1))))
     (with-output-to-temp-buffer "*Help*"
-      (emerge-eval-in-buffer emerge-A-buffer
+      (with-current-buffer emerge-A-buffer
 			     (if buffer-file-name
 				 (progn
 				   (princ "File A is: ")
@@ -2148,7 +2134,7 @@
 				 (princ "Buffer A is: ")
 				 (princ (buffer-name))))
 			     (princ "\n"))
-      (emerge-eval-in-buffer emerge-B-buffer
+      (with-current-buffer emerge-B-buffer
 			     (if buffer-file-name
 				 (progn
 				   (princ "File B is: ")
@@ -2158,7 +2144,7 @@
 				 (princ (buffer-name))))
 			     (princ "\n"))
       (if emerge-ancestor-buffer
-	    (emerge-eval-in-buffer emerge-ancestor-buffer
+	    (with-current-buffer emerge-ancestor-buffer
 				   (if buffer-file-name
 				       (progn
 					 (princ "Ancestor file is: ")
@@ -2229,9 +2215,9 @@
     ;; check that this is a valid difference
     (emerge-validate-difference)
     ;; get the point values and old difference
-    (let ((A-point (emerge-eval-in-buffer emerge-A-buffer
+    (let ((A-point (with-current-buffer emerge-A-buffer
 					  (point-marker)))
-	  (B-point (emerge-eval-in-buffer emerge-B-buffer
+	  (B-point (with-current-buffer emerge-B-buffer
 					  (point-marker)))
 	  (merge-point (point-marker))
 	  (old-diff (aref emerge-difference-list n)))
@@ -2313,10 +2299,10 @@
       (while success
 	(setq size (min size (- bottom-a top-a) (- bottom-b top-b)
 			(- bottom-m top-m)))
-	(setq sa (emerge-eval-in-buffer emerge-A-buffer
+	(setq sa (with-current-buffer emerge-A-buffer
 					(buffer-substring top-a
 							  (+ size top-a))))
-	(setq sb (emerge-eval-in-buffer emerge-B-buffer
+	(setq sb (with-current-buffer emerge-B-buffer
 					(buffer-substring top-b
 							  (+ size top-b))))
 	(setq sm (buffer-substring top-m (+ size top-m)))
@@ -2335,10 +2321,10 @@
       (while success
 	(setq size (min size (- bottom-a top-a) (- bottom-b top-b)
 			(- bottom-m top-m)))
-	(setq sa (emerge-eval-in-buffer emerge-A-buffer
+	(setq sa (with-current-buffer emerge-A-buffer
 					(buffer-substring (- bottom-a size)
 							  bottom-a)))
-	(setq sb (emerge-eval-in-buffer emerge-B-buffer
+	(setq sb (with-current-buffer emerge-B-buffer
 					(buffer-substring (- bottom-b size)
 							  bottom-b)))
 	(setq sm (buffer-substring (- bottom-m size) bottom-m))
@@ -2351,14 +2337,14 @@
     ;; {top,bottom}-{a,b,m} are now set at the new beginnings and ends
     ;; of the difference regions.  Move them to the beginning of lines, as
     ;; appropriate.
-    (emerge-eval-in-buffer emerge-A-buffer
+    (with-current-buffer emerge-A-buffer
 			   (goto-char top-a)
 			   (beginning-of-line)
 			   (aset diff 0 (point-marker))
 			   (goto-char bottom-a)
 			   (beginning-of-line 2)
 			   (aset diff 1 (point-marker)))
-    (emerge-eval-in-buffer emerge-B-buffer
+    (with-current-buffer emerge-B-buffer
 			   (goto-char top-b)
 			   (beginning-of-line)
 			   (aset diff 2 (point-marker))
@@ -2413,7 +2399,7 @@
   ;; search for the point in the A buffer, using the markers
   ;; for the beginning and end of the differences in the A buffer
   (emerge-find-difference1 arg
-			   (emerge-eval-in-buffer emerge-A-buffer (point))
+			   (with-current-buffer emerge-A-buffer (point))
 			   0 1))
 
 (defun emerge-find-difference-B (arg)
@@ -2426,7 +2412,7 @@
   ;; search for the point in the B buffer, using the markers
   ;; for the beginning and end of the differences in the B buffer
   (emerge-find-difference1 arg
-			   (emerge-eval-in-buffer emerge-B-buffer (point))
+			   (with-current-buffer emerge-B-buffer (point))
 			   2 3))
 
 (defun emerge-find-difference1 (arg location begin end)
@@ -2474,16 +2460,19 @@
   (let* ((valid-diff
 	 (and (>= emerge-current-difference 0)
 	      (< emerge-current-difference emerge-number-of-differences)))
-	(diff (and valid-diff
-		   (aref emerge-difference-list emerge-current-difference)))
-	(merge-line (emerge-line-number-in-buf 4 5))
-	(A-line (emerge-eval-in-buffer emerge-A-buffer
-				       (emerge-line-number-in-buf 0 1)))
-	(B-line (emerge-eval-in-buffer emerge-B-buffer
-				       (emerge-line-number-in-buf 2 3))))
+	 (emerge-line-diff (and valid-diff
+				(aref emerge-difference-list
+				      emerge-current-difference)))
+	 (merge-line (emerge-line-number-in-buf 4 5))
+	 (A-line (with-current-buffer emerge-A-buffer
+					(emerge-line-number-in-buf 0 1)))
+	 (B-line (with-current-buffer emerge-B-buffer
+					(emerge-line-number-in-buf 2 3))))
     (message "At lines: merge = %d, A = %d, B = %d"
 	     merge-line A-line B-line)))
 
+(defvar emerge-line-diff)
+
 (defun emerge-line-number-in-buf (begin-marker end-marker)
   (let (temp)
     (setq temp (save-excursion
@@ -2491,9 +2480,9 @@
 		 (1+ (count-lines 1 (point)))))
     (if valid-diff
 	(progn
-	  (if (> (point) (aref diff begin-marker))
+	  (if (> (point) (aref emerge-line-diff begin-marker))
 	      (setq temp (- temp emerge-before-flag-lines)))
-	  (if (> (point) (aref diff end-marker))
+	  (if (> (point) (aref emerge-line-diff end-marker))
 	      (setq temp (- temp emerge-after-flag-lines)))))
     temp))
 
@@ -2548,30 +2537,32 @@
 	(error "Register does not contain text"))
     (emerge-combine-versions-internal template force)))
 
-(defun emerge-combine-versions-internal (template force)
+(defun emerge-combine-versions-internal (emerge-combine-template force)
   (let ((operate
-	 (function (lambda ()
-		     (emerge-combine-versions-edit merge-begin merge-end
-						   A-begin A-end B-begin B-end)
-		     (if emerge-auto-advance
-			 (emerge-next-difference))))))
+	 (lambda ()
+	   (emerge-combine-versions-edit merge-begin merge-end
+					 A-begin A-end B-begin B-end)
+	   (if emerge-auto-advance
+	       (emerge-next-difference)))))
     (emerge-select-version force operate operate operate)))
 
+(defvar emerge-combine-template)
+
 (defun emerge-combine-versions-edit (merge-begin merge-end
 				     A-begin A-end B-begin B-end)
-  (emerge-eval-in-buffer
+  (with-current-buffer
    emerge-merge-buffer
    (delete-region merge-begin merge-end)
    (goto-char merge-begin)
    (let ((i 0))
-     (while (< i (length template))
-       (let ((c (aref template i)))
+     (while (< i (length emerge-combine-template))
+       (let ((c (aref emerge-combine-template i)))
 	 (if (= c ?%)
 	     (progn
 	       (setq i (1+ i))
 	       (setq c
 		     (condition-case nil
-			 (aref template i)
+			 (aref emerge-combine-template i)
 		       (error ?%)))
 	       (cond ((= c ?a)
 		      (insert-buffer-substring emerge-A-buffer A-begin A-end))
@@ -2620,7 +2611,7 @@
 (defun emerge-place-flags-in-buffer (buffer difference before-index
 					    after-index)
   (if buffer
-      (emerge-eval-in-buffer
+      (with-current-buffer
        buffer
        (emerge-place-flags-in-buffer1 difference before-index after-index))
     (emerge-place-flags-in-buffer1 difference before-index after-index)))
@@ -2689,7 +2680,7 @@
   (run-hooks 'emerge-unselect-hook))
 
 (defun emerge-remove-flags-in-buffer (buffer before after)
-  (emerge-eval-in-buffer
+  (with-current-buffer
    buffer
    (let ((buffer-read-only nil))
      ;; remove the flags, if they're there
@@ -2838,11 +2829,11 @@
       (while (< x-begin x-end)
 	;; bite off and compare no more than 1000 characters at a time
 	(let* ((compare-length (min (- x-end x-begin) 1000))
-	       (x-string (emerge-eval-in-buffer
+	       (x-string (with-current-buffer
 			  buffer-x
 			  (buffer-substring x-begin
 					    (+ x-begin compare-length))))
-	       (y-string (emerge-eval-in-buffer
+	       (y-string (with-current-buffer
 			  buffer-y
 			  (buffer-substring y-begin
 					    (+ y-begin compare-length)))))
@@ -2879,9 +2870,9 @@
 ;; A "function" is anything that funcall can handle as an argument.
 
 (defun emerge-save-variables (vars)
-  (mapcar (function (lambda (v) (if (symbolp v)
-				    (symbol-value v)
-				  (funcall (car v)))))
+  (mapcar (lambda (v) (if (symbolp v)
+			  (symbol-value v)
+			(funcall (car v))))
 	  vars))
 
 (defun emerge-restore-variables (vars values)
@@ -2972,7 +2963,7 @@
 ;; buffer.
 (defun emerge-copy-modes (buffer)
   ;; Set the major mode
-  (funcall (emerge-eval-in-buffer buffer major-mode)))
+  (funcall (with-current-buffer buffer major-mode)))
 
 ;; Define a key, even if a prefix of it is defined
 (defun emerge-force-define-key (keymap key definition)
@@ -3163,11 +3154,11 @@
 			       (aref s i))
 			    65536))
       (setq i (1+ i)))
-    (mapconcat (function (lambda (b)
-			   (setq b (+ (% b 93) ?!))
-			   (if (>= b ?/)
-			       (setq b (1+ b)))
-			   (char-to-string b)))
+    (mapconcat (lambda (b)
+		 (setq b (+ (% b 93) ?!))
+		 (if (>= b ?/)
+		     (setq b (1+ b)))
+		 (char-to-string b))
 	       bins "")))
 
 ;; Quote any /s in a string by replacing them with \!.
@@ -3205,5 +3196,4 @@
 
 (provide 'emerge)
 
-;; arch-tag: a575f092-6e44-400e-b8a2-4124e9377585
 ;;; emerge.el ends here
--- a/lisp/vc/log-edit.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/vc/log-edit.el	Mon Nov 08 14:19:54 2010 +0900
@@ -572,6 +572,16 @@
 	(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.")
+(put 'log-edit-rewrite-fixes 'safe-local-variable
+     (lambda (v) (and (stringp (car-safe v)) (stringp (cdr v)))))
+
 (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 +603,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 +696,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 +713,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 +819,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 +837,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/vc/vc-arch.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/vc/vc-arch.el	Mon Nov 08 14:19:54 2010 +0900
@@ -428,7 +428,7 @@
 	(message "There are unresolved conflicts in %s"
 		 (file-name-nondirectory rej))))))
 
-(defun vc-arch-checkin (files rev comment  &optional extra-args-ignored)
+(defun vc-arch-checkin (files rev comment)
   (if rev (error "Committing to a specific revision is unsupported"))
   ;; FIXME: This implementation probably only works for singleton filesets
   (let ((summary (file-relative-name (car files) (vc-arch-root (car files)))))
--- a/lisp/vc/vc-cvs.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/vc/vc-cvs.el	Mon Nov 08 14:19:54 2010 +0900
@@ -314,7 +314,7 @@
                   (directory-file-name dir))))
     (eq dir t)))
 
-(defun vc-cvs-checkin (files rev comment  &optional extra-args-ignored)
+(defun vc-cvs-checkin (files rev comment)
   "CVS-specific version of `vc-backend-checkin'."
   (unless (or (not rev) (vc-cvs-valid-revision-number-p rev))
     (if (not (vc-cvs-valid-symbolic-tag-name-p rev))
--- a/lisp/vc/vc-mtn.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/vc/vc-mtn.el	Mon Nov 08 14:19:54 2010 +0900
@@ -175,7 +175,7 @@
 
 (declare-function log-edit-extract-headers "log-edit" (headers string))
 
-(defun vc-mtn-checkin (files rev comment  &optional extra-args-ignored)
+(defun vc-mtn-checkin (files rev comment)
   (apply 'vc-mtn-command nil 0 files
 	 (nconc (list "commit" "-m")
 		(log-edit-extract-headers '(("Author" . "--author")
--- a/lisp/vc/vc-rcs.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/vc/vc-rcs.el	Mon Nov 08 14:19:54 2010 +0900
@@ -349,7 +349,7 @@
 	 (yes-or-no-p (format "Directory %s is empty; remove it? " dir))
 	 (delete-directory dir))))
 
-(defun vc-rcs-checkin (files rev comment &optional extra-args-ignored)
+(defun vc-rcs-checkin (files rev comment)
   "RCS-specific version of `vc-backend-checkin'."
   (let ((switches (vc-switches 'RCS 'checkin)))
     ;; Now operate on the files
--- a/lisp/vc/vc-sccs.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/vc/vc-sccs.el	Mon Nov 08 14:19:54 2010 +0900
@@ -237,7 +237,7 @@
       (stringp (vc-sccs-search-project-dir (or (file-name-directory file) "")
 					   (file-name-nondirectory file)))))
 
-(defun vc-sccs-checkin (files rev comment &optional extra-args-ignored)
+(defun vc-sccs-checkin (files rev comment)
   "SCCS-specific version of `vc-backend-checkin'."
   (dolist (file (vc-expand-dirs files))
     (apply 'vc-sccs-do-command nil 0 "delta" (vc-name file)
--- a/lisp/w32-fns.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/w32-fns.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/w32-vars.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/wid-edit.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/woman.el	Mon Nov 08 14:19:54 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
@@ -2475,23 +2475,23 @@
 Start at FROM and re-scan new text as appropriate."
   (goto-char from)
   (let ((woman0-if-to (make-marker))
-	request woman0-macro-alist
+	woman-request woman0-macro-alist
 	(woman0-search-regex-start woman0-search-regex-start)
 	(woman0-search-regex
 	 (concat woman0-search-regex-start woman0-search-regex-end))
 	woman0-rename-alist)
     (set-marker-insertion-type woman0-if-to t)
     (while (re-search-forward woman0-search-regex nil t)
-      (setq request (match-string 1))
-      (cond ((string= request "ig") (woman0-ig))
-	    ((string= request "if") (woman0-if "if"))
-	    ((string= request "ie") (woman0-if "ie"))
-	    ((string= request "el") (woman0-el))
-	    ((string= request "so") (woman0-so))
-	    ((string= request "rn") (woman0-rn))
-	    ((string= request "de") (woman0-de))
-	    ((string= request "am") (woman0-de 'append))
-	    (t                      (woman0-macro request))))
+      (setq woman-request (match-string 1))
+      (cond ((string= woman-request "ig") (woman0-ig))
+	    ((string= woman-request "if") (woman0-if "if"))
+	    ((string= woman-request "ie") (woman0-if "ie"))
+	    ((string= woman-request "el") (woman0-el))
+	    ((string= woman-request "so") (woman0-so))
+	    ((string= woman-request "rn") (woman0-rn))
+	    ((string= woman-request "de") (woman0-de))
+	    ((string= woman-request "am") (woman0-de 'append))
+	    (t                      (woman0-macro woman-request))))
     (set-marker woman0-if-to nil)
     (woman0-rename)
     ;; Should now re-run `woman0-roff-buffer' if any renaming was
@@ -2522,6 +2522,7 @@
   (goto-char from)			; necessary!
   (woman2-process-escapes to 'numeric))
 
+;; request does not appear to be used dynamically by any callees.
 (defun woman0-if (request)
   ".if/ie c anything -- Discard unless c evaluates to true.
 Remember condition for use by a subsequent `.el'.
@@ -2573,6 +2574,7 @@
 	(woman-if-ignore woman0-if-to request) ; ERROR!
       (woman-if-body request woman0-if-to (eq c negated)))))
 
+;; request is not used dynamically by any callees.
 (defun woman-if-body (request to delete) ; should be reversed as `accept'?
   "Process if-body, including \\{ ... \\}.
 REQUEST is the invoking directive without the leading dot.
@@ -2629,6 +2631,7 @@
 	 (if (looking-at "[ \t]*\\{") (search-forward "\\}"))
 	 (forward-line 1))))
 
+;; request is not used dynamically by any callees.
 (defun woman-if-ignore (to request)
   "Ignore but warn about an if request ending at TO, named REQUEST."
   (WoMan-warn-ignored request "ignored -- condition not handled!")
@@ -2760,15 +2763,17 @@
   (beginning-of-line)			; delete .de/am line
   (woman-delete-line 1))
 
-(defun woman0-macro (request)
-  "Process the macro call named REQUEST."
+;; request may be used dynamically (woman-interpolate-macro calls
+;; woman-forward-arg).
+(defun woman0-macro (woman-request)
+  "Process the macro call named WOMAN-REQUEST."
   ;; Leaves point at start of new text.
-  (let ((macro (assoc request woman0-macro-alist)))
+  (let ((macro (assoc woman-request woman0-macro-alist)))
     (if macro
 	(woman-interpolate-macro (cdr macro))
       ;; SHOULD DELETE THE UNINTERPRETED REQUEST!!!!!
       ;; Output this message once only per call (cf. strings)?
-      (WoMan-warn "Undefined macro %s not interpolated!" request))))
+      (WoMan-warn "Undefined macro %s not interpolated!" woman-request))))
 
 (defun woman-interpolate-macro (macro)
   "Interpolate (.de) or append (.am) expansion of MACRO into the buffer."
@@ -2985,8 +2990,10 @@
 
 ;;; Formatting macros that do not cause a break:
 
-(defvar request)  ; Bound locally by woman1-roff-buffer
-(defvar unquote)  ; Bound locally by woman1-roff-buffer
+;; Bound locally by woman[012]-roff-buffer, and also, annoyingly and
+;; confusingly, as a function argument.  Use dynamically in
+;; woman-unquote and woman-forward-arg.
+(defvar woman-request)
 
 (defun woman-unquote (to)
   "Delete any double-quote characters between point and TO.
@@ -3001,7 +3008,7 @@
 	(setq in-quote (not in-quote))
 	))
     (if in-quote
-	(WoMan-warn "Unpaired \" in .%s arguments." request))))
+	(WoMan-warn "Unpaired \" in .%s arguments." woman-request))))
 
 (defsubst woman-unquote-args ()
   "Delete any double-quote characters up to the end of the line."
@@ -3010,7 +3017,7 @@
 (defun woman1-roff-buffer ()
   "Process non-breaking requests."
   (let ((case-fold-search t)
-	request fn unquote)
+	woman-request fn woman1-unquote)
     (while
 	;; Find next control line:
 	(re-search-forward woman-request-regexp nil t)
@@ -3018,14 +3025,14 @@
        ;; Construct woman function to call:
        ((setq fn (intern-soft
 		  (concat "woman1-"
-			  (setq request (match-string 1)))))
+			  (setq woman-request (match-string 1)))))
 	(if (get fn 'notfont)		; not a font-change request
 	    (funcall fn)
 	  ;; Delete request or macro name:
 	  (woman-delete-match 0)
 	  ;; If no args then apply to next line else unquote args
-	  ;; (unquote is used by called function):
-	  (setq unquote (not (eolp)))
+	  ;; (woman1-unquote is used by called function):
+	  (setq woman1-unquote (not (eolp)))
 	  (if (eolp) (delete-char 1))
 ;	    ;; Hide leading control character in unquoted argument:
 ;	    (cond ((memq (following-char) '(?. ?'))
@@ -3034,7 +3041,7 @@
 	  ;; Call the appropriate function:
 	  (funcall fn)
 	  ;; Hide leading control character in quoted argument (only):
-	  (if (and unquote (memq (following-char) '(?. ?')))
+	  (if (and woman1-unquote (memq (following-char) '(?. ?')))
 	      (insert "\\&"))))))))
 
 ;;; Font-changing macros:
@@ -3047,6 +3054,8 @@
   ".I -- Set words of current line in italic font."
   (woman1-B-or-I ".ft I\n"))
 
+(defvar woman1-unquote)          ; bound locally by woman1-roff-buffer
+
 (defun woman1-B-or-I (B-or-I)
   ".B/I -- Set words of current line in bold/italic font.
 B-OR-I is the appropriate complete control line."
@@ -3055,7 +3064,7 @@
   ;; Return to bol to process .SM/.B, .B/.if etc.
   ;; or start of first arg to hide leading control char.
   (save-excursion
-    (if unquote
+    (if woman1-unquote
 	(woman-unquote-args)
       (while (looking-at "^[.']") (forward-line))
       (end-of-line)
@@ -3102,11 +3111,12 @@
   ;; Return to start of first arg to hide leading control char:
   (save-excursion
     (setq fonts (cdr fonts))
-    (woman-forward-arg unquote 'concat)	; unquote is bound above
+    ;; woman1-unquote is bound in woman1-roff-buffer.
+    (woman-forward-arg woman1-unquote 'concat)
     (while (not (eolp))
       (insert (car fonts))
       (setq fonts (cdr fonts))
-      (woman-forward-arg unquote 'concat)) ; unquote is bound above
+      (woman-forward-arg woman1-unquote 'concat))
     (insert "\\fR")))
 
 (defun woman-forward-arg (&optional unquote concat)
@@ -3123,7 +3133,7 @@
 	  (re-search-forward "\"\\|$"))
 	(if (eq (preceding-char) ?\")
 	    (if unquote (delete-char -1))
-	  (WoMan-warn "Unpaired \" in .%s arguments." request)))
+	  (WoMan-warn "Unpaired \" in .%s arguments." woman-request)))
     ;; (re-search-forward "[^\\\n] \\|$")	; inconsistent
     (skip-syntax-forward "^ "))
   (cond ((null concat) (skip-chars-forward " \t")) ; don't skip eol!
@@ -3338,7 +3348,12 @@
 
 ;;; Output translation:
 
-(defvar translations nil)  ; Also bound locally by woman2-roff-buffer
+;; This is only set by woman2-tr.  It is bound locally in woman2-roff-buffer.
+;; It is also used by woman-translate.  woman-translate may be called
+;; outside the scope of woman2-roff-buffer (by experiment).  Therefore
+;; this used to be globally bound to nil, to avoid an error.  Instead
+;; we can use bound-and-true-p in woman-translate.
+(defvar woman-translations)
 ;; A list of the form (\"[ace]\" (a . b) (c . d) (e . ?\ )) or nil.
 
 (defun woman-get-next-char ()
@@ -3358,8 +3373,8 @@
   ;; This should be an update, but consing onto the front of the alist
   ;; has the same effect and match duplicates should not matter.
   ;; Initialize translation data structures:
-  (let ((matches (car translations))
-	(alist (cdr translations))
+  (let ((matches (car woman-translations))
+	(alist (cdr woman-translations))
 	a b)
     ;; `matches' must be a string:
     (setq matches
@@ -3381,15 +3396,15 @@
 	  (if (= (string-to-char matches) ?\])
 	      (substring matches 3)
 	    (concat "[" matches))
-	  translations (cons matches alist))
+	  woman-translations (cons matches alist))
     ;; Format any following text:
     (woman2-format-paragraphs to)))
 
 (defsubst woman-translate (to)
   "Translate up to marker TO.  Do this last of all transformations."
-  (if translations
-      (let ((matches (car translations))
-	    (alist (cdr translations))
+  (if (bound-and-true-p woman-translations)
+      (let ((matches (car woman-translations))
+	    (alist (cdr woman-translations))
 	    ;; Translations are case-sensitive, eg ".tr ab" does not
 	    ;; affect "A" (bug#6849).
 	    (case-fold-search nil))
@@ -3528,8 +3543,8 @@
 ;      (WoMan-warn "Unimplemented numerical operator `%c' in %s"
 ;		  (following-char)
 ;		  (buffer-substring
-;		   (save-excursion (beginning-of-line) (point))
-;		   (save-excursion (end-of-line) (point))))
+;		   (line-beginning-position)
+;		   (line-end-position)))
 ;      (skip-syntax-forward "^ "))
     value
     ))
@@ -3598,7 +3613,7 @@
 	    (WoMan-warn "Numeric/register argument error: %s"
 			(buffer-substring
 			 (point)
-			 (save-excursion (end-of-line) (point))))
+			 (line-end-position)))
 	    (skip-syntax-forward "^ ")
 	    0)
 	(goto-char (match-end 0))
@@ -3633,7 +3648,7 @@
 	(insert-and-inherit (symbol-function 'insert-and-inherit))
 	(set-text-properties (symbol-function 'set-text-properties))
 	(woman-registers woman-registers)
-	fn request translations
+	fn woman-request woman-translations
 	tab-stop-list)
     (set-marker-insertion-type to t)
     ;; ?roff does not squeeze multiple spaces, but does fill, so...
@@ -3649,13 +3664,13 @@
            ;; Construct woman function to call:
            ((setq fn (intern-soft
                       (concat "woman2-"
-                              (setq request (match-string 1)))))
+                              (setq woman-request (match-string 1)))))
             ;; Delete request or macro name:
             (woman-delete-match 0))
            ;; Unrecognised request:
            ((prog1 nil
-              ;; (WoMan-warn ".%s request ignored!" request)
-              (WoMan-warn-ignored request "ignored!")
+              ;; (WoMan-warn ".%s request ignored!" woman-request)
+              (WoMan-warn-ignored woman-request "ignored!")
               ;; (setq fn 'woman2-LP)
               ;; AVOID LEAVING A BLANK LINE!
               ;; (setq fn 'woman2-format-paragraphs)
@@ -3748,8 +3763,7 @@
 			(buffer-substring start here))
 	  (delete-region here (point)))))
   ;; Embolden heading (point is at end of heading):
-  (woman-set-face
-   (save-excursion (beginning-of-line) (point)) (point) 'woman-bold)
+  (woman-set-face (line-beginning-position) (point) 'woman-bold)
   (forward-line)
   (delete-blank-lines)
   (setq woman-left-margin woman-default-indent)
@@ -3768,8 +3782,7 @@
   (setq woman-leave-blank-lines nil)
   ;; Optionally embolden heading (point is at beginning of heading):
   (if woman-bold-headings
-      (woman-set-face
-       (point) (save-excursion (end-of-line) (point)) 'woman-bold))
+      (woman-set-face (point) (line-end-position) 'woman-bold))
   (forward-line)
   (setq woman-left-margin woman-default-indent
 	woman-nofill nil)		; fill output lines
@@ -4361,7 +4374,7 @@
 	       eol n)
 	  (if type
 	      (setq tab (woman-get-tab-stop tab)
-		    eol (save-excursion (end-of-line) (point))
+		    eol (line-end-position)
 		    n (save-excursion
 			(search-forward "\t" eol t))
 		    n (- (if n (1- n) eol) (point))
@@ -4486,12 +4499,13 @@
   (setq format (apply 'format format args))
   (WoMan-log-1 (concat "**  " format)))
 
+;; request is not used dynamically by any callees.
 (defun WoMan-warn-ignored (request ignored)
   "Log a warning message about ignored directive REQUEST.
 IGNORED is a string appended to the log message."
   (let ((tail
 	 (buffer-substring (point)
-			   (save-excursion (end-of-line) (point)))))
+			   (line-end-position))))
     (if (and (> (length tail) 0)
 	     (/= (string-to-char tail) ?\ ))
 	(setq tail (concat " " tail)))
@@ -4557,5 +4571,4 @@
 
 (provide 'woman)
 
-;; arch-tag: eea35e90-552f-4712-a94b-d9ffd3db7651
 ;;; woman.el ends here
--- a/lisp/x-dnd.el	Mon Nov 08 14:19:24 2010 +0900
+++ b/lisp/x-dnd.el	Mon Nov 08 14:19:54 2010 +0900
@@ -220,7 +220,7 @@
 DATA is encoded in utf-16.  Decode the URL and call `x-dnd-handle-uri-list'."
   ;; Mozilla and applications based on it (Galeon for example) uses
   ;; text/unicode, but it is impossible to tell if it is le or be.  Use what
-  ;; the machine Emacs runs on use.  This looses if dropping between machines
+  ;; the machine Emacs runs on use.  This loses if dropping between machines
   ;; with different endian, but it is the best we can do.
   (let* ((coding (if (eq (byteorder) ?B) 'utf-16be 'utf-16le))
 	 (string (decode-coding-string data coding))
@@ -766,5 +766,4 @@
 
 (provide 'x-dnd)
 
-;; arch-tag: b621fb7e-50da-4323-850b-5fc71ae64621
 ;;; x-dnd.el ends here
--- a/make-dist	Mon Nov 08 14:19:24 2010 +0900
+++ b/make-dist	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/msdos/ChangeLog	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/msdos/sed1v2.inp	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/msdos/sed6.inp	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/nextstep/ChangeLog	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/nextstep/README	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/nt/ChangeLog	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/nt/INSTALL	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/nt/README	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/nt/README.W32	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/ChangeLog	Mon Nov 08 14:19:54 2010 +0900
@@ -1,3 +1,484 @@
+2010-11-07  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* xfns.c (set_machine_and_pid_properties): Let X set WM_CLIENT_MACHINE.
+
+	* xdisp.c (note_mode_line_or_margin_highlight): Initialize
+	Cursor to No_Cursor for HAVE_WINDOW_SYSTEM also.
+
+2010-11-06  Eli Zaretskii  <eliz@gnu.org>
+
+	* xfns.c (Fx_show_tip): If any of the tool-tip text lines is R2L,
+	adjust width of tool-tip frame to the width of text, excluding the
+	stretch glyph at the beginning of R2L glyph rows.
+
+	* w32fns.c (Fx_show_tip): Likewise.
+
+2010-11-06  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* nsfont.m: Include termchar for new mouse-highlight.
+	(nsfont_draw): Use MOUSE_HL_INFO.
+
+2010-11-05  Eli Zaretskii  <eliz@gnu.org>
+
+	Unify mouse-highlight code for all GUI and TTY sessions.
+
+	* term.c: Remove static mouse_face_* variables.  All users
+	changed.
+	(term_show_mouse_face, term_clear_mouse_face)
+	(fast_find_position, term_mouse_highlight): Functions deleted.
+	(tty_draw_row_with_mouse_face): New function.
+	(term_mouse_movement): Call note_mouse_highlight instead of
+	term_mouse_highlight.
+
+	* nsterm.m (ns_update_window_begin, ns_update_window_end)
+	(ns_update_end, x_destroy_window, ns_frame_up_to_date)
+	(ns_dumpglyphs_box_or_relief, ns_maybe_dumpglyphs_background)
+	(ns_dumpglyphs_image, ns_dumpglyphs_stretch)
+	(ns_initialize_display_info, keyDown, mouseMoved, mouseExited):
+	Replace Display_Info with Mouse_HLInfo everywhere where
+	mouse_face_* members were accessed for mouse highlight purposes.
+
+	* xterm.c (x_update_window_begin, x_update_window_end)
+	(x_update_end, XTframe_up_to_date, x_set_mouse_face_gc)
+	(handle_one_xevent, x_free_frame_resources, x_term_init): Replace
+	Display_Info with Mouse_HLInfo everywhere where mouse_face_*
+	members were accessed for mouse highlight purposes.
+
+	* w32term.c (x_update_window_begin, x_update_window_end)
+	(x_update_end, w32_read_socket, x_free_frame_resources)
+	(w32_initialize_display_info): Replace Display_Info with
+	Mouse_HLInfo everywhere where mouse_face_* members were accessed
+	for mouse highlight purposes.
+
+	* xdisp.c (show_mouse_face, note_mode_line_or_margin_highlight)
+	(note_mouse_highlight) [HAVE_WINDOW_SYSTEM]: Don't run GUI code
+	unless the frame is on a window-system.
+	(get_tool_bar_item, handle_tool_bar_click)
+	(note_tool_bar_highlight, draw_glyphs, erase_phys_cursor)
+	(show_mouse_face, clear_mouse_face, coords_in_mouse_face_p)
+	(note_mode_line_or_margin_highlight, note_mouse_highlight)
+	(x_clear_window_mouse_face, cancel_mouse_face, expose_frame):
+	Replace Display_Info with Mouse_HLInfo everywhere where
+	mouse_face_* members were accessed for mouse highlight purposes.
+	(coords_in_mouse_face_p): Move prototype out of the
+	HAVE_WINDOW_SYSTEM conditional.
+	(x_y_to_hpos_vpos, frame_to_window_pixel_xy): Move out of the
+	HAVE_WINDOW_SYSTEM block.
+	(try_window_id) [HAVE_GPM || MSDOS]: Call
+	x_clear_window_mouse_face.
+	(draw_row_with_mouse_face): Implementation for HAVE_WINDOW_SYSTEM
+	systems.  Call tty_draw_row_with_mouse_face for TTY systems.
+	(show_mouse_face): Call draw_row_with_mouse_face, instead of
+	calling draw_glyphs directly.
+	(show_mouse_face, clear_mouse_face, coords_in_mouse_face_p)
+	(cursor_in_mouse_face_p, rows_from_pos_range)
+	(mouse_face_from_buffer_pos, mouse_face_from_string_pos)
+	(note_mode_line_or_margin_highlight, note_mouse_highlight)
+	(x_clear_window_mouse_face, cancel_mouse_face): Move out of the
+	HAVE_WINDOW_SYSTEM block.  Ifdef away window-system specific
+	fragments.
+	(note_mouse_highlight): Call popup_activated for MSDOS as well.
+	Clear mouse highlight if pointer is over glyphs whose OBJECT is an
+	integer.
+	(mouse_face_from_buffer_pos): Add parentheses around && within ||.
+	(x_consider_frame_title, tool_bar_lines_needed): Move
+	prototypes to HAVE_WINDOW_SYSTEM-only part.
+	(get_window_cursor_type): Move inside a HAVE_WINDOW_SYSTEM-only
+	part.  Remove "#ifdef HAVE_WINDOW_SYSTEM" from body of function.
+	(null_glyph_slice): Move declaration into HAVE_WINDOW_SYSTEM-only
+	part.
+
+	* dispnew.c (mirror_make_current): Set Y coordinate of the
+	mode-line and header-line rows.
+	(init_display): Setup initial frame's output_data for text
+	terminal frames.
+
+	* xmenu.c (popup_activated): Don't define on MSDOS, which now has
+	its own definition on msdos.c.
+
+	* msdos.c (show_mouse_face, clear_mouse_face)
+	(fast_find_position, IT_note_mode_line_highlight)
+	(IT_note_mouse_highlight): Functions deleted.
+	(IT_frame_up_to_date, dos_rawgetc): Call note_mouse_highlight
+	instead of IT_note_mouse_highlight.
+	(draw_row_with_mouse_face, popup_activated): New functions.
+	(dos_set_window_size, draw_row_with_mouse_face, IT_update_begin)
+	(IT_update_end, IT_frame_up_to_date, internal_terminal_init)
+	(dos_rawgetc): Replace Display_Info with Mouse_HLInfo everywhere
+	where mouse_face_* members were accessed for mouse highlight
+	purposes.
+
+	* msdos.h (initialize_msdos_display): Add prototype.
+
+	* frame.h (MOUSE_HL_INFO): New macro.
+
+	* lisp.h (Mouse_HLInfo): New data type.
+
+	* xterm.h (struct x_display_info):
+	* w32term.h (struct w32_display_info):
+	* nsterm.h (struct ns_display_info):
+	* termchar.h (struct tty_display_info): Use it instead of
+	mouse_face_* members.
+
+	* dispextern.h (show_mouse_face, clear_mouse_face): Update type of
+	1st argument.
+	(frame_to_window_pixel_xy, note_mouse_highlight)
+	(x_clear_window_mouse_face, cancel_mouse_face, clear_mouse_face)
+	(show_mouse_face, cursor_in_mouse_face_p): Move prototypes out of
+	HAVE_WINDOW_SYSTEM conditional.
+	(draw_row_with_mouse_face): Declare prototype.
+	(tty_draw_row_with_mouse_face): Declare prototype.
+
+2010-11-05  Eli Zaretskii  <eliz@gnu.org>
+
+	* term.c (append_glyphless_glyph, produce_glyphless_glyph): Remove
+	unused variables.
+
+2010-11-05  Adrian Robert  <Adrian.B.Robert@gmail.com>
+
+	* nsterm.m (EmacsView-mouseExited:): Correct error in conditional
+	logic pointed out by Eli Zaretskii.
+
+2010-11-04  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* coding.c (coding-category-list): Refer to set-coding-system-priority
+	instead of the obsolete set-coding-priority in the doc string.
+
+
+2010-11-04  Adrian Robert  <Adrian.B.Robert@gmail.com>
+
+	* nsfont.m (nsfont_draw):  Correct previous patch to return
+	correct value.
+	* nsimage.m (EmacsImage-setXBMColor:): Correct previous patch:
+	don't change the method signature, change the return.
+
+2010-11-04  Ismail Donmez  <ismail@namtrac.org>  (tiny change)
+
+	* nsfont.m (nsfont_draw)
+	* nsimage.m (EmacsImage-setXBMColor:)
+	* nsterm.m (EmacsView-performDragOperation:): Correct empty return.
+
+2010-11-03  Julien Danjou  <julien@danjou.info>
+
+	* image.c (gif_load): Add support for transparency and specified
+	:background.
+
+2010-11-01  Kenichi Handa  <handa@m17n.org>
+
+	* dispextern.h (lookup_glyphless_char_display): Extern it.
+
+	* termhooks.h (struct terminal): New member charset_list.
+
+	* coding.c (Fset_terminal_coding_system_internal): Set the
+	`charset_list' member of struct terminal.
+
+	* term.c (produce_glyphs): Handle the case it->what == IT_GLYPHLESS.
+	(append_glyphless_glyph, produce_glyphless_glyph): New functions.
+
+	* xdisp.c (lookup_glyphless_char_display): Make it non-static.
+	(lookup_glyphless_char_display): Set it->what at the end.
+	(last_glyphless_glyph_frame, last_glyphless_glyph_face_id)
+	(last_glyphless_glyph_merged_face_id): Make them non-static.
+
+	* w32term.c (x_draw_glyphless_glyph_string_foreground):
+	Fix the arg with_background for font->driver->draw.
+
+2010-11-01  Kenichi Handa  <handa@m17n.org>
+
+	* w32gui.h (STORE_XCHAR2B, XCHAR2B_BYTE1, XCHAR2B_BYTE2):
+	Surround chp by parentheses.
+
+2010-11-01  Kenichi Handa  <handa@m17n.org>
+
+	Implement various display methods for glyphless characters.
+
+	* xdisp.c (Qglyphless_char, Vglyphless_char_display)
+	(Qglyphless_char_display, Qhexa_code, Qempty_box, Qthin_space)
+	(Qzero_width): New variables.
+	(THIN_SPACE_WIDTH): New macro.
+	(lookup_glyphless_char_display): New funciton.
+	(last_glyphless_glyph_frame, last_glyphless_glyph_face_id)
+	(last_glyphless_glyph_merged_face_id): New variables.
+	(get_next_display_element): Check glyphless characters.
+	(redisplay_internal): Initialize last_glyphless_glyph_frame and
+	last_glyphless_glyph_face_id.
+	(fill_glyphless_glyph_string): New function.
+	(BUILD_GLYPHLESS_GLYPH_STRING): New macro.
+	(BUILD_GLYPH_STRINGS): Handle the case GLYPHLESS_GLYPH.
+	(append_glyphless_glyph, produce_glyphless_glyph): New functions.
+	(x_produce_glyphs): If a suitable font is not found, produce a
+	glyphless glyph.  Handle the case it->what == IT_GLYPHLESS.
+	(syms_of_xdisp): Intern and staticpro Qglyphless_char,
+	Qglyphless_char_display, Qhexa_code, Qempty_box, Qthin_space, and
+	Qzero_width.
+	(Vglyphless_char_display): Declare it as a Lisp variable.
+
+	* dispextern.h (enum glyph_type): Add GLYPHLESS_GLYPH.
+	(struct glyph): Change the size of the member "type" to 3.
+	Add glyphless to the union slice and u.
+	(enum display_element_type): Add IT_GLYPHLESS.
+	(enum glyphless_display_method): New enum.
+	(struct it): New member glyphless_method.
+	(Vglyphless_char_display): Extern it.
+
+	* xterm.c (x_draw_glyphless_glyph_string_foreground): New function.
+	(x_draw_glyph_string): Handle the case GLYPHLESS_GLYPH.
+
+	* w32term.c (x_draw_glyphless_glyph_string_foreground): New function.
+	(x_draw_glyph_string): Handle the case GLYPHLESS_GLYPH.
+
+	* nsterm.m (ns_draw_glyph_string): Handle the case
+	GLYPHLESS_GLYPH (the detail is not yet implemented).
+
+2010-10-31  Glenn Morris  <rgm@gnu.org>
+
+	* xterm.c (x_connection_closed) [USE_X_TOOLKIT]: Fix merge, maybe.
+
+	* frame.c (syms_of_frame) <tool-bar-mode>:
+	Default to nil if !HAVE_WINDOW_SYSTEM.  (Bug#7299)
+
+2010-10-31  Chong Yidong  <cyd@stupidchicken.com>
+
+	* xterm.c (x_connection_closed): Print informative error message
+	when aborting on GTK.  This requires using shut_down_emacs
+	directly instead of Fkill_emacs.
+
+2010-10-29  Eli Zaretskii  <eliz@gnu.org>
+
+	* emacs.c (main): Call syms_of_filelock unconditionally.
+
+	* filelock.c (syms_of_filelock): Move out of #ifdef CLASH_DETECTION
+	clause, but keep part of it conditioned on CLASH_DETECTION.
+
+2010-10-29  Glenn Morris  <rgm@gnu.org>
+
+	* nsfns.m (Fx-display-save-under, Fx-open-connection)
+	(Fxw-color-defined-p, Fxw-display-color-p, Fx-show-tip):
+	* w32fns.c (Fxw_color_defined_p, Fx_open_connection):
+	* xfns.c (Fxw_color_defined_p, Fx_open_connection):
+	Sync docs between X, W32, NS.
+
+	* buffer.c (syms_of_buffer) <abbrev-mode, transient-mark-mode>:
+	* frame.c (syms_of_frame) <tool-bar-mode>: Move doc here from Lisp.
+
+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 +28605,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 +28625,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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/ChangeLog.2	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/ChangeLog.3	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/ChangeLog.7	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/ChangeLog.8	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/ChangeLog.9	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/Makefile.in	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/atimer.c	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/buffer.c	Mon Nov 08 14:19:54 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.
 
@@ -5600,7 +5600,8 @@
 		     doc: /* Local (mode-specific) abbrev table of current buffer.  */);
 
   DEFVAR_PER_BUFFER ("abbrev-mode", &current_buffer->abbrev_mode, Qnil,
-		     doc: /* Non-nil turns on automatic expansion of abbrevs as they are inserted.  */);
+		     doc: /*  Non-nil if Abbrev mode is enabled.
+Use the command `abbrev-mode' to change this variable.  */);
 
   DEFVAR_PER_BUFFER ("case-fold-search", &current_buffer->case_fold_search,
 		     Qnil,
@@ -6098,11 +6099,23 @@
 If the buffer has never been shown in a window, the value is nil.  */);
 
   DEFVAR_LISP ("transient-mark-mode", &Vtransient_mark_mode,
-	       doc: /* */);
+	       doc: /*  Non-nil if Transient Mark mode is enabled.
+See the command `transient-mark-mode' for a description of this minor mode.
+
+Non-nil also enables highlighting of the region whenever the mark is active.
+The variable `highlight-nonselected-windows' controls whether to highlight
+all windows or just the selected window.
+
+If the value is `lambda', that enables Transient Mark mode temporarily.
+After any subsequent action that would normally deactivate the mark
+\(such as buffer modification), Transient Mark mode is turned off.
+
+If the value is (only . OLDVAL), that enables Transient Mark mode
+temporarily.  After any subsequent point motion command that is not
+shift-translated, or any other action that would normally deactivate
+the mark (such as buffer modification), the value of
+`transient-mark-mode' is set to OLDVAL.  */);
   Vtransient_mark_mode = Qnil;
-  /* The docstring is in simple.el.  If we put it here, it would be
-     overwritten when transient-mark-mode is defined using
-     define-minor-mode.  */
 
   DEFVAR_LISP ("inhibit-read-only", &Vinhibit_read_only,
 	       doc: /* *Non-nil means disregard read-only status of buffers or characters.
@@ -6140,8 +6153,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 +6235,3 @@
   Fput (intern_c_string ("erase-buffer"), Qdisabled, Qt);
 }
 
-/* arch-tag: e48569bf-69a9-4b65-a23b-8e68769436e1
-   (do not change this comment) */
--- a/src/buffer.h	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/buffer.h	Mon Nov 08 14:19:54 2010 +0900
@@ -1,7 +1,8 @@
 /* Header file for the buffer manipulation primitives.
-   Copyright (C) 1985, 1986, 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, 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.
 
@@ -459,7 +460,7 @@
     struct Lisp_Marker *markers;
 
     /* Usually 0.  Temporarily set to 1 in decode_coding_gap to
-       prevent Fgarbage_collect from shrinking the gap and loosing
+       prevent Fgarbage_collect from shrinking the gap and losing
        not-yet-decoded bytes.  */
     int inhibit_shrinking;
   };
@@ -1019,5 +1020,3 @@
 #define PER_BUFFER_VALUE(BUFFER, OFFSET) \
       (*(Lisp_Object *)((OFFSET) + (char *) (BUFFER)))
 
-/* arch-tag: 679305dd-d41c-4a50-b170-3caf5c97b2d1
-   (do not change this comment) */
--- a/src/ccl.c	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/ccl.c	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/cmds.c	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/coding.c	Mon Nov 08 14:19:54 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.
@@ -9297,15 +9297,20 @@
        doc: /* Internal use only.  */)
   (Lisp_Object coding_system, Lisp_Object terminal)
 {
-  struct coding_system *terminal_coding = TERMINAL_TERMINAL_CODING (get_terminal (terminal, 1));
+  struct terminal *term = get_terminal (terminal, 1);
+  struct coding_system *terminal_coding = TERMINAL_TERMINAL_CODING (term);
   CHECK_SYMBOL (coding_system);
   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;
+  if (terminal_coding->common_flags & CODING_REQUIRE_ENCODING_MASK)
+    term->charset_list = coding_charset_list (terminal_coding);
+  else
+    term->charset_list = Fcons (Qascii, Qnil);
   return Qnil;
 }
 
@@ -9318,7 +9323,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 +9357,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 +9725,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))
@@ -10554,7 +10559,7 @@
 one algorithm agrees with a byte sequence of source text, the coding
 system bound to the corresponding coding-category is selected.
 
-Don't modify this variable directly, but use `set-coding-priority'.  */);
+Don't modify this variable directly, but use `set-coding-system-priority'.  */);
   {
     int i;
 
--- a/src/config.in	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/config.in	Mon Nov 08 14:19:54 2010 +0900
@@ -1059,6 +1059,9 @@
 /* Define to `int' if <sys/types.h> does not define. */
 #undef pid_t
 
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+#undef size_t
+
 /* Define to any substitute for sys_siglist. */
 #undef sys_siglist
 
@@ -1097,17 +1100,14 @@
 #include config_opsysfile
 #include config_machfile
 
-/* Set up some defines, C and LD flags for NeXTstep interface on GNUstep.
-  (There is probably a better place to do this, but right now the Cocoa
-   side does this in s/darwin.h and we cannot
-   parallel this exactly since GNUstep is multi-OS.  */
-#ifdef HAVE_NS
-# ifdef NS_IMPL_GNUSTEP
 /* GNUstep needs a bit more pure memory.  Of the existing knobs,
-SYSTEM_PURESIZE_EXTRA seems like the least likely to cause problems.  */
+   SYSTEM_PURESIZE_EXTRA seems like the least likely to cause problems.
+  (There is probably a better place to do this, but right now the
+   Cocoa side does this in s/darwin.h and we cannot parallel this
+   exactly since GNUstep is multi-OS.  */
+#if defined HAVE_NS && defined NS_IMPL_GNUSTEP
 #  define SYSTEM_PURESIZE_EXTRA 30000
-# endif /* NS_IMPL_GNUSTEP */
-#endif /* HAVE_NS */
+#endif
 
 /* SIGTYPE is the macro we actually use.  */
 #ifndef SIGTYPE
--- a/src/dispextern.h	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/dispextern.h	Mon Nov 08 14:19:54 2010 +0900
@@ -69,6 +69,11 @@
 typedef XImagePtr XImagePtr_or_DC;
 #endif
 
+#ifndef HAVE_WINDOW_SYSTEM
+typedef int Cursor;
+#define No_Cursor (0)
+#endif
+
 #ifndef NativeRectangle
 #define NativeRectangle int
 #endif
@@ -279,6 +284,9 @@
   /* Glyph describes a static composition.  */
   COMPOSITE_GLYPH,
 
+  /* Glyph describes a glyphless character.  */
+  GLYPHLESS_GLYPH,
+
   /* Glyph describes an image.  */
   IMAGE_GLYPH,
 
@@ -333,7 +341,7 @@
 
   /* Which kind of glyph this is---character, image etc.  Value
      should be an enumerator of type enum glyph_type.  */
-  unsigned type : 2;
+  unsigned type : 3;
 
   /* 1 means this glyph was produced from multibyte text.  Zero
      means it was produced from unibyte text, i.e. charsets aren't
@@ -402,6 +410,11 @@
     /* Start and end indices of glyphs of a graphme cluster of a
        composition (type == COMPOSITE_GLYPH).  */
     struct { int from, to; } cmp;
+    /* Pixel offsets for upper and lower part of the acronym.  */
+    struct {
+      short upper_xoff, upper_yoff;
+      short lower_xoff, lower_yoff;
+    } glyphless;
   } slice;
 
   /* A union of sub-structures for different glyph types.  */
@@ -433,6 +446,19 @@
     }
     stretch;
 
+    /* Sub-stretch for type == GLYPHLESS_GLYPH.  */
+    struct
+    {
+      /* Value is an enum of the type glyphless_display_method.  */
+      unsigned method : 2;
+      /* 1 iff this glyph is for a character of no font. */
+      unsigned for_no_font : 1;
+      /* Length of acronym or hexadecimal code string (at most 8).  */
+      unsigned len : 4;
+      /* Character to display.  Actually we need only 22 bits.  */
+      unsigned ch : 26;
+    } glyphless;
+
     /* Used to compare all bit-fields above in one step.  */
     unsigned val;
   } u;
@@ -1918,6 +1944,9 @@
   /* A composition (static and automatic).  */
   IT_COMPOSITION,
 
+  /* A glyphless character (e.g. ZWNJ, LRE).  */
+  IT_GLYPHLESS,
+
   /* An image.  */
   IT_IMAGE,
 
@@ -1964,6 +1993,20 @@
   WINDOW_WRAP
 };
 
+/* An enumerator for the method of displaying glyphless characters.  */
+
+enum glyphless_display_method
+  {
+    /* Display a thin (1-pixel width) space.  */
+    GLYPHLESS_DISPLAY_THIN_SPACE,
+    /* Display an empty box of proper width.  */
+    GLYPHLESS_DISPLAY_EMPTY_BOX,
+    /* Display an acronym string in a box.  */
+    GLYPHLESS_DISPLAY_ACRONYM,
+    /* Display a hexadecimal character code in a box.  */
+    GLYPHLESS_DISPLAY_HEXA_CODE
+  };
+
 struct it_slice
 {
   Lisp_Object x;
@@ -2295,6 +2338,10 @@
      PRODUCE_GLYPHS, this should be set beforehand too.  */
   int char_to_display;
 
+  /* If what == IT_GLYPHLESS, the method to display such a
+     character.  */
+  enum glyphless_display_method glyphless_method;
+
   /* If what == IT_IMAGE, the id of the image to display.  */
   int image_id;
 
@@ -2976,9 +3023,10 @@
 extern Lisp_Object Vmouse_autoselect_window;
 extern int unibyte_display_via_language_environment;
 extern EMACS_INT underline_minimum_offset;
+extern Lisp_Object Vglyphless_char_display;
 
 extern void reseat_at_previous_visible_line_start (struct it *);
-
+extern Lisp_Object lookup_glyphless_char_display (int, struct it *);
 extern int calc_pixel_width_or_height (double *, struct it *, Lisp_Object,
                                        struct font *, int, int *);
 
@@ -3017,28 +3065,31 @@
 extern void x_clear_cursor (struct window *);
 extern void x_draw_vertical_border (struct window *w);
 
-extern void frame_to_window_pixel_xy (struct window *, int *, int *);
 extern int get_glyph_string_clip_rects (struct glyph_string *,
                                         NativeRectangle *, int);
 extern void get_glyph_string_clip_rect (struct glyph_string *,
                                         NativeRectangle *nr);
 extern Lisp_Object find_hot_spot (Lisp_Object, int, int);
-extern void note_mouse_highlight (struct frame *, int, int);
-extern void x_clear_window_mouse_face (struct window *);
-extern void cancel_mouse_face (struct frame *);
 
 extern void handle_tool_bar_click (struct frame *,
                                    int, int, int, unsigned int);
 
-/* msdos.c defines its own versions of these functions. */
-extern int clear_mouse_face (Display_Info *);
-extern void show_mouse_face (Display_Info *, enum draw_glyphs_face);
-extern int cursor_in_mouse_face_p (struct window *w);
-
 extern void expose_frame (struct frame *, int, int, int, int);
 extern int x_intersect_rectangles (XRectangle *, XRectangle *,
                                    XRectangle *);
-#endif
+#endif	/* HAVE_WINDOW_SYSTEM */
+
+extern void frame_to_window_pixel_xy (struct window *, int *, int *);
+extern void note_mouse_highlight (struct frame *, int, int);
+extern void x_clear_window_mouse_face (struct window *);
+extern void cancel_mouse_face (struct frame *);
+extern int clear_mouse_face (Mouse_HLInfo *);
+extern void show_mouse_face (Mouse_HLInfo *, enum draw_glyphs_face);
+extern int cursor_in_mouse_face_p (struct window *w);
+extern void draw_row_with_mouse_face (struct window *, int, struct glyph_row *,
+				      int, int, enum draw_glyphs_face);
+extern void tty_draw_row_with_mouse_face (struct window *, struct glyph_row *,
+					  int, int, enum draw_glyphs_face);
 
 /* Flags passed to try_window.  */
 #define TRY_WINDOW_CHECK_MARGINS	(1 << 0)
--- a/src/dispnew.c	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/dispnew.c	Mon Nov 08 14:19:54 2010 +0900
@@ -2893,6 +2893,14 @@
 	      else
 		swap_glyph_pointers (desired_row, current_row);
 	      current_row->enabled_p = 1;
+
+	      /* Set the Y coordinate of the mode/header line's row.
+		 It is needed in draw_row_with_mouse_face to find the
+		 screen coordinates.  (Window-based redisplay sets
+		 this in update_window, but no one seems to do that
+		 for frame-based redisplay.)  */
+	      if (current_row->mode_line_p)
+		current_row->y = row;
 	    }
 	}
 
@@ -6416,6 +6424,12 @@
     f->terminal = t;
 
     t->reference_count++;
+#ifdef MSDOS
+    f->output_data.tty->display_info = &the_only_display_info;
+#else
+    if (f->output_method == output_termcap)
+      create_tty_output (f);
+#endif
     t->display_info.tty->top_frame = selected_frame;
     change_frame_size (XFRAME (selected_frame),
                        FrameRows (t->display_info.tty),
@@ -6583,13 +6597,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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/emacs.c	Mon Nov 08 14:19:54 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
@@ -1505,9 +1509,7 @@
       syms_of_doc ();
       syms_of_editfns ();
       syms_of_emacs ();
-#ifdef CLASH_DETECTION
       syms_of_filelock ();
-#endif /* CLASH_DETECTION */
       syms_of_indent ();
       syms_of_insdel ();
       /* syms_of_keymap (); */
@@ -2507,6 +2509,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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/eval.c	Mon Nov 08 14:19:54 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/filelock.c	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/filelock.c	Mon Nov 08 14:19:54 2010 +0900
@@ -730,6 +730,8 @@
   boot_time_initialized = 0;
 }
 
+#endif /* CLASH_DETECTION */
+
 void
 syms_of_filelock (void)
 {
@@ -737,12 +739,12 @@
 	       doc: /* The directory for writing temporary files.  */);
   Vtemporary_file_directory = Qnil;
 
+#ifdef CLASH_DETECTION
   defsubr (&Sunlock_buffer);
   defsubr (&Slock_buffer);
   defsubr (&Sfile_locked_p);
+#endif
 }
 
-#endif /* CLASH_DETECTION */
-
 /* arch-tag: e062676d-50b2-4be0-ab96-197c81b181a1
    (do not change this comment) */
--- a/src/font.c	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/font.c	Mon Nov 08 14:19:54 2010 +0900
@@ -1,8 +1,9 @@
 /* font.c -- "Font" primitives.
-   Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
-   Copyright (C) 2006, 2007, 2008, 2009, 2010
-     National Institute of Advanced Industrial Science and Technology (AIST)
-     Registration Number H13PRO009
+
+Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+Copyright (C) 2006, 2007, 2008, 2009, 2010
+  National Institute of Advanced Industrial Science and Technology (AIST)
+  Registration Number H13PRO009
 
 This file is part of GNU Emacs.
 
@@ -3443,7 +3444,7 @@
       if (NILP (entity))
 	return Qnil;
     }
-  /* Don't loose the original name that was put in initially.  We need
+  /* Don't lose the original name that was put in initially.  We need
      it to re-apply the font when font parameters (like hinting or dpi) have
      changed.  */
   entity = font_open_for_lface (f, entity, attrs, spec);
@@ -3514,7 +3515,7 @@
   args[1] = make_unibyte_string (name, strlen (name));
   spec = Ffont_spec (2, args);
   ret = font_open_by_spec (f, spec);
-  /* Do not loose name originally put in.  */
+  /* Do not lose name originally put in.  */
   if (!NILP (ret))
     font_put_extra (ret, QCuser_spec, args[1]);
 
@@ -3723,6 +3724,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 +4539,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)
@@ -5347,5 +5400,3 @@
   Vfont_log = egetenv ("EMACS_FONT_LOG") ? Qnil : Qt;
 }
 
-/* arch-tag: 74c9475d-5976-4c93-a327-942ae3072846
-   (do not change this comment) */
--- a/src/font.h	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/font.h	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/frame.c	Mon Nov 08 14:19:54 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,12 +4563,24 @@
   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,
-               doc: /* Non-nil if Tool-Bar mode is enabled.  */);
+               doc: /* Non-nil if Tool-Bar mode is enabled.
+See the command `tool-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 `tool-bar-mode'.  */);
+#ifdef HAVE_WINDOW_SYSTEM
   Vtool_bar_mode = Qt;
+#else
+  Vtool_bar_mode = Qnil;
+#endif
 
   DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame,
 		 doc: /* Minibufferless frames use this frame's minibuffer.
@@ -4623,6 +4660,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 +4669,3 @@
 
 }
 
-/* arch-tag: 7dbf2c69-9aad-45f8-8296-db893d6dd039
-   (do not change this comment) */
--- a/src/frame.h	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/frame.h	Mon Nov 08 14:19:54 2010 +0900
@@ -544,6 +544,20 @@
 #define FRAME_WINDOW_P(f) (0)
 #endif
 
+/* Return a pointer to the structure holding information about the
+   region of text, if any, that is currently shown in mouse-face on
+   frame F.  We need to define two versions because a TTY-only build
+   does not have FRAME_X_DISPLAY_INFO.  */
+#ifdef HAVE_WINDOW_SYSTEM
+# define MOUSE_HL_INFO(F)					\
+   (FRAME_WINDOW_P(F)						\
+    ? &(FRAME_X_DISPLAY_INFO(F)->mouse_highlight)		\
+    : &(((F)->output_data.tty->display_info)->mouse_highlight))
+#else
+# define MOUSE_HL_INFO(F)					\
+    (&(((F)->output_data.tty->display_info)->mouse_highlight))
+#endif
+
 /* Nonzero if frame F is still alive (not deleted).  */
 #define FRAME_LIVE_P(f) ((f)->terminal != 0)
 
--- a/src/ftfont.c	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/ftfont.c	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/gnutls.c	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/gtkutil.c	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/image.c	Mon Nov 08 14:19:54 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)
@@ -7089,12 +7096,15 @@
 static const int interlace_start[] = {0, 4, 2, 1};
 static const int interlace_increment[] = {8, 8, 4, 2};
 
+#define GIF_LOCAL_DESCRIPTOR_EXTENSION 249
+
 static int
 gif_load (struct frame *f, struct image *img)
 {
   Lisp_Object file, specified_file;
   Lisp_Object specified_data;
   int rc, width, height, x, y, i;
+  boolean transparent_p;
   XImagePtr ximg;
   ColorMapObject *gif_color_map;
   unsigned long pixel_colors[256];
@@ -7103,6 +7113,7 @@
   int ino, image_height, image_width;
   gif_memory_source memsrc;
   unsigned char *raster;
+  unsigned int transparency_color_index;
 
   specified_file = image_spec_value (img->spec, QCfile, NULL);
   specified_data = image_spec_value (img->spec, QCdata, NULL);
@@ -7175,6 +7186,18 @@
       return 0;
     }
 
+  for (i = 0; i < gif->SavedImages[ino].ExtensionBlockCount; i++)
+    if ((gif->SavedImages[ino].ExtensionBlocks[i].Function
+	 == GIF_LOCAL_DESCRIPTOR_EXTENSION)
+	&& gif->SavedImages[ino].ExtensionBlocks[i].ByteCount == 4
+	/* Transparency enabled?  */
+	&& gif->SavedImages[ino].ExtensionBlocks[i].Bytes[0] & 1)
+      {
+	transparent_p = 1;
+	transparency_color_index
+	  = (unsigned char) gif->SavedImages[ino].ExtensionBlocks[i].Bytes[3];
+      }
+
   img->corners[TOP_CORNER] = gif->SavedImages[ino].ImageDesc.Top;
   img->corners[LEFT_CORNER] = gif->SavedImages[ino].ImageDesc.Left;
   image_height = gif->SavedImages[ino].ImageDesc.Height;
@@ -7213,10 +7236,22 @@
   if (gif_color_map)
     for (i = 0; i < gif_color_map->ColorCount; ++i)
       {
-        int r = gif_color_map->Colors[i].Red << 8;
-        int g = gif_color_map->Colors[i].Green << 8;
-        int b = gif_color_map->Colors[i].Blue << 8;
-        pixel_colors[i] = lookup_rgb_color (f, r, g, b);
+	if (transparent_p && transparency_color_index == i)
+	  {
+	    Lisp_Object specified_bg
+	      = image_spec_value (img->spec, QCbackground, NULL);
+	    pixel_colors[i] = STRINGP (specified_bg)
+	      ? x_alloc_image_color (f, img, specified_bg,
+				     FRAME_BACKGROUND_PIXEL (f))
+	      : FRAME_BACKGROUND_PIXEL (f);
+	  }
+	else
+	  {
+	    int r = gif_color_map->Colors[i].Red << 8;
+	    int g = gif_color_map->Colors[i].Green << 8;
+	    int b = gif_color_map->Colors[i].Blue << 8;
+	    pixel_colors[i] = lookup_rgb_color (f, r, g, b);
+	  }
       }
 
 #ifdef COLOR_TABLE_SUPPORT
@@ -8583,7 +8618,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 +8694,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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/insdel.c	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/lisp.h	Mon Nov 08 14:19:54 2010 +0900
@@ -1563,6 +1563,41 @@
 /* The ID of the mode line highlighting face.  */
 #define GLYPH_MODE_LINE_FACE 1
 
+/* Structure to hold mouse highlight data.  This is here because other
+   header files need it for defining struct x_output etc.  */
+typedef struct {
+  /* These variables describe the range of text currently shown in its
+     mouse-face, together with the window they apply to.  As long as
+     the mouse stays within this range, we need not redraw anything on
+     its account.  Rows and columns are glyph matrix positions in
+     MOUSE_FACE_WINDOW.  */
+  int mouse_face_beg_row, mouse_face_beg_col;
+  int mouse_face_beg_x, mouse_face_beg_y;
+  int mouse_face_end_row, mouse_face_end_col;
+  int mouse_face_end_x, mouse_face_end_y;
+  int mouse_face_past_end;
+  Lisp_Object mouse_face_window;
+  int mouse_face_face_id;
+  Lisp_Object mouse_face_overlay;
+
+  /* 1 if a mouse motion event came and we didn't handle it right away because
+     gc was in progress.  */
+  int mouse_face_deferred_gc;
+
+  /* FRAME and X, Y position of mouse when last checked for
+     highlighting.  X and Y can be negative or out of range for the frame.  */
+  struct frame *mouse_face_mouse_frame;
+  int mouse_face_mouse_x, mouse_face_mouse_y;
+
+  /* Nonzero means defer mouse-motion highlighting.  */
+  int mouse_face_defer;
+
+  /* Nonzero means that the mouse highlight should not be shown.  */
+  int mouse_face_hidden;
+
+  int mouse_face_image_state;
+} Mouse_HLInfo;
+
 /* Data type checking */
 
 #define NILP(x)  EQ (x, Qnil)
@@ -3300,6 +3335,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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/lread.c	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/makefile.w32-in	Mon Nov 08 14:19:54 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/msdos.c	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/msdos.c	Mon Nov 08 14:19:54 2010 +0900
@@ -584,14 +584,14 @@
   if (current_rows != *rows || current_cols != *cols)
     {
       struct frame *f = SELECTED_FRAME();
-      struct tty_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
-      Lisp_Object window = dpyinfo->mouse_face_window;
+      Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
+      Lisp_Object window = hlinfo->mouse_face_window;
 
       if (! NILP (window) && XFRAME (XWINDOW (window)->frame) == f)
 	{
-	  dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1;
-	  dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
-	  dpyinfo->mouse_face_window = Qnil;
+	  hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
+	  hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
+	  hlinfo->mouse_face_window = Qnil;
 	}
     }
 
@@ -941,551 +941,79 @@
 
 static int mouse_preempted = 0;	/* non-zero when XMenu gobbles mouse events */
 
-/* Set the mouse pointer shape according to whether it is in the
-   area where the mouse highlight is in effect.  */
-static void
-IT_set_mouse_pointer (int mode)
-{
-  /* A no-op for now.  DOS text-mode mouse pointer doesn't offer too
-     many possibilities to change its shape, and the available
-     functionality pretty much sucks (e.g., almost every reasonable
-     shape will conceal the character it is on).  Since the color of
-     the pointer changes in the highlighted area, it is not clear to
-     me whether anything else is required, anyway.  */
-}
-
-/* Display the active region described by mouse_face_*
-   in its mouse-face if HL > 0, in its normal face if HL = 0.  */
-static void
-show_mouse_face (struct tty_display_info *dpyinfo, int hl)
+int
+popup_activated (void)
 {
-  struct window *w = XWINDOW (dpyinfo->mouse_face_window);
-  struct frame *f = XFRAME (WINDOW_FRAME (w));
-  int i;
-  struct face *fp;
-  struct tty_display_info *tty = FRAME_TTY (f);
-
-
-  /* If window is in the process of being destroyed, don't bother
-     doing anything.  */
-  if (w->current_matrix == NULL)
-    goto set_cursor_shape;
-
-  /* Recognize when we are called to operate on rows that don't exist
-     anymore.  This can happen when a window is split.  */
-  if (dpyinfo->mouse_face_end_row >= w->current_matrix->nrows)
-    goto set_cursor_shape;
-
-  /* There's no sense to do anything if the mouse face isn't realized.  */
-  if (hl > 0)
-    {
-      if (dpyinfo->mouse_face_hidden)
-	goto set_cursor_shape;
-
-      fp = FACE_FROM_ID (SELECTED_FRAME(), dpyinfo->mouse_face_face_id);
-      if (!fp)
-	goto set_cursor_shape;
-    }
-
-  /* Note that mouse_face_beg_row etc. are window relative.  */
-  for (i = dpyinfo->mouse_face_beg_row;
-       i <= dpyinfo->mouse_face_end_row;
-       i++)
-    {
-      int start_hpos, end_hpos;
-      struct glyph_row *row = MATRIX_ROW (w->current_matrix, i);
-
-      /* Don't do anything if row doesn't have valid contents.  */
-      if (!row->enabled_p)
-	continue;
-
-      /* For all but the first row, the highlight starts at column 0.  */
-      if (i == dpyinfo->mouse_face_beg_row)
-	start_hpos = dpyinfo->mouse_face_beg_col;
-      else
-	start_hpos = 0;
-
-      if (i == dpyinfo->mouse_face_end_row)
-	end_hpos = dpyinfo->mouse_face_end_col;
-      else
-	end_hpos = row->used[TEXT_AREA];
-
-      if (end_hpos <= start_hpos)
-	continue;
-      /* Record that some glyphs of this row are displayed in
-         mouse-face.  */
-      row->mouse_face_p = hl > 0;
-      if (hl > 0)
-	{
-	  int vpos = row->y + WINDOW_TOP_EDGE_Y (w);
-	  int kstart = start_hpos + WINDOW_LEFT_EDGE_X (w);
-	  int nglyphs = end_hpos - start_hpos;
-	  int offset = ScreenPrimary + 2*(vpos*screen_size_X + kstart) + 1;
-	  int start_offset = offset;
-
-	  if (tty->termscript)
-	    fprintf (tty->termscript, "\n<MH+ %d-%d:%d>",
-		     kstart, kstart + nglyphs - 1, vpos);
-
-	  mouse_off ();
-	  IT_set_face (dpyinfo->mouse_face_face_id);
-	  /* Since we are going to change only the _colors_ of the
-	     displayed text, there's no need to go through all the
-	     pain of generating and encoding the text from the glyphs.
-	     Instead, we simply poke the attribute byte of each
-	     affected position in video memory with the colors
-	     computed by IT_set_face!  */
-	  _farsetsel (_dos_ds);
-	  while (nglyphs--)
-	    {
-	      _farnspokeb (offset, ScreenAttrib);
-	      offset += 2;
-	    }
-	  if (screen_virtual_segment)
-	    dosv_refresh_virtual_screen (start_offset, end_hpos - start_hpos);
-	  mouse_on ();
-	}
-      else
-	{
-	  /* We are removing a previously-drawn mouse highlight.  The
-	     safest way to do so is to redraw the glyphs anew, since
-	     all kinds of faces and display tables could have changed
-	     behind our back.  */
-	  int nglyphs = end_hpos - start_hpos;
-	  int save_x = new_pos_X, save_y = new_pos_Y;
-
-	  if (end_hpos >= row->used[TEXT_AREA])
-	    nglyphs = row->used[TEXT_AREA] - start_hpos;
-
-	  /* IT_write_glyphs writes at cursor position, so we need to
-	     temporarily move cursor coordinates to the beginning of
-	     the highlight region.  */
-	  new_pos_X = start_hpos + WINDOW_LEFT_EDGE_X (w);
-	  new_pos_Y = row->y + WINDOW_TOP_EDGE_Y (w);
-
-	  if (tty->termscript)
-	    fprintf (tty->termscript, "<MH- %d-%d:%d>",
-		     new_pos_X, new_pos_X + nglyphs - 1, new_pos_Y);
-	  IT_write_glyphs (f, row->glyphs[TEXT_AREA] + start_hpos, nglyphs);
-	  if (tty->termscript)
-	    fputs ("\n", tty->termscript);
-	  new_pos_X = save_x;
-	  new_pos_Y = save_y;
-	}
-    }
-
- set_cursor_shape:
-  /* Change the mouse pointer shape.  */
-  IT_set_mouse_pointer (hl);
-}
-
-/* Clear out the mouse-highlighted active region.
-   Redraw it un-highlighted first.  */
-static void
-clear_mouse_face (struct tty_display_info *dpyinfo)
-{
-  if (!dpyinfo->mouse_face_hidden && ! NILP (dpyinfo->mouse_face_window))
-    show_mouse_face (dpyinfo, 0);
-
-  dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1;
-  dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
-  dpyinfo->mouse_face_window = Qnil;
-}
-
-/* Find the glyph matrix position of buffer position POS in window W.
-   *HPOS and *VPOS are set to the positions found.  W's current glyphs
-   must be up to date.  If POS is above window start return (0, 0).
-   If POS is after end of W, return end of last line in W.  */
-static int
-fast_find_position (struct window *w, int pos, int *hpos, int *vpos)
-{
-  int i, lastcol, line_start_position, maybe_next_line_p = 0;
-  int yb = window_text_bottom_y (w);
-  struct glyph_row *row = MATRIX_ROW (w->current_matrix, 0), *best_row = row;
-
-  while (row->y < yb)
-    {
-      if (row->used[TEXT_AREA])
-	line_start_position = row->glyphs[TEXT_AREA]->charpos;
-      else
-	line_start_position = 0;
-
-      if (line_start_position > pos)
-	break;
-      /* If the position sought is the end of the buffer,
-	 don't include the blank lines at the bottom of the window.  */
-      else if (line_start_position == pos
-	       && pos == BUF_ZV (XBUFFER (w->buffer)))
-	{
-	  maybe_next_line_p = 1;
-	  break;
-	}
-      else if (line_start_position > 0)
-	best_row = row;
-
-      /* Don't overstep the last matrix row, lest we get into the
-	 never-never land... */
-      if (row->y + 1 >= yb)
-	break;
-
-      ++row;
-    }
-
-  /* Find the right column within BEST_ROW.  */
-  lastcol = 0;
-  row = best_row;
-  for (i = 0; i < row->used[TEXT_AREA]; i++)
-    {
-      struct glyph *glyph = row->glyphs[TEXT_AREA] + i;
-      int charpos;
-
-      charpos = glyph->charpos;
-      if (charpos == pos)
-	{
-	  *hpos = i;
-	  *vpos = row->y;
-	  return 1;
-	}
-      else if (charpos > pos)
-	break;
-      else if (charpos > 0)
-	lastcol = i;
-    }
-
-  /* If we're looking for the end of the buffer,
-     and we didn't find it in the line we scanned,
-     use the start of the following line.  */
-  if (maybe_next_line_p)
-    {
-      ++row;
-      lastcol = 0;
-    }
-
-  *vpos = row->y;
-  *hpos = lastcol + 1;
-  return 0;
-}
-
-/* Take proper action when mouse has moved to the mode or top line of
-   window W, x-position X.  MODE_LINE_P non-zero means mouse is on the
-   mode line.  X is relative to the start of the text display area of
-   W, so the width of fringes and scroll bars must be subtracted
-   to get a position relative to the start of the mode line.  */
-static void
-IT_note_mode_line_highlight (struct window *w, int x, int mode_line_p)
-{
-  struct glyph_row *row;
-
-  if (mode_line_p)
-    row = MATRIX_MODE_LINE_ROW (w->current_matrix);
-  else
-    row = MATRIX_HEADER_LINE_ROW (w->current_matrix);
-
-  if (row->enabled_p)
-    {
-      struct glyph *glyph, *end;
-      Lisp_Object help;
-
-      /* Find the glyph under X.  */
-      glyph = (row->glyphs[TEXT_AREA]
-	       + x
-	       /* in case someone implements scroll bars some day... */
-	       - WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH (w));
-      end = glyph + row->used[TEXT_AREA];
-      if (glyph < end
-	  && STRINGP (glyph->object)
-	  && STRING_INTERVALS (glyph->object)
-	  && glyph->charpos >= 0
-	  && glyph->charpos < SCHARS (glyph->object))
-	{
-	  /* If we're on a string with `help-echo' text property,
-	     arrange for the help to be displayed.  This is done by
-	     setting the global variable help_echo to the help string.  */
-	  help = Fget_text_property (make_number (glyph->charpos),
-				     Qhelp_echo, glyph->object);
-	  if (!NILP (help))
-	    {
-	      help_echo_string = help;
-	      XSETWINDOW (help_echo_window, w);
-	      help_echo_object = glyph->object;
-	      help_echo_pos = glyph->charpos;
-	    }
-	}
-    }
+  return mouse_preempted;
 }
 
-/* Take proper action when the mouse has moved to position X, Y on
-   frame F as regards highlighting characters that have mouse-face
-   properties.  Also de-highlighting chars where the mouse was before.
-   X and Y can be negative or out of range.  */
-static void
-IT_note_mouse_highlight (struct frame *f, int x, int y)
+/* Draw TEXT_AREA glyphs between START and END of glyph row ROW on
+   window W.  X is relative to TEXT_AREA in W.  HL is a face override
+   for drawing the glyphs.  */
+void
+tty_draw_row_with_mouse_face (struct window *w, struct glyph_row *row,
+			      int start_hpos, int end_hpos,
+			      enum draw_glyphs_face hl)
 {
-  struct tty_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
-  enum window_part part = ON_NOTHING;
-  Lisp_Object window;
-  struct window *w;
-
-  /* When a menu is active, don't highlight because this looks odd.  */
-  if (mouse_preempted)
-    return;
-
-  if (NILP (Vmouse_highlight)
-      || !f->glyphs_initialized_p)
-    return;
-
-  dpyinfo->mouse_face_mouse_x = x;
-  dpyinfo->mouse_face_mouse_y = y;
-  dpyinfo->mouse_face_mouse_frame = f;
-
-  if (dpyinfo->mouse_face_defer)
-    return;
-
-  if (gc_in_progress)
-    {
-      dpyinfo->mouse_face_deferred_gc = 1;
-      return;
-    }
-
-  /* Which window is that in?  */
-  window = window_from_coordinates (f, x, y, &part, &x, &y, 0);
-
-  /* If we were displaying active text in another window, clear that.  */
-  if (! EQ (window, dpyinfo->mouse_face_window))
-    clear_mouse_face (dpyinfo);
-
-  /* Not on a window -> return.  */
-  if (!WINDOWP (window))
-    return;
-
-  /* Convert to window-relative coordinates.  */
-  w = XWINDOW (window);
-
-  if (part == ON_MODE_LINE || part == ON_HEADER_LINE)
+  struct frame *f = XFRAME (WINDOW_FRAME (w));
+  struct tty_display_info *tty = FRAME_TTY (f);
+  Mouse_HLInfo *hlinfo = &tty->mouse_highlight;
+
+  if (hl == DRAW_MOUSE_FACE)
     {
-      /* Mouse is on the mode or top line.  */
-      IT_note_mode_line_highlight (w, x, part == ON_MODE_LINE);
-      return;
-    }
-
-  IT_set_mouse_pointer (0);
-
-  /* Are we in a window whose display is up to date?
-     And verify the buffer's text has not changed.  */
-  if (part == ON_TEXT
-      && EQ (w->window_end_valid, w->buffer)
-      && XFASTINT (w->last_modified) == BUF_MODIFF (XBUFFER (w->buffer))
-      && (XFASTINT (w->last_overlay_modified)
-	  == BUF_OVERLAY_MODIFF (XBUFFER (w->buffer))))
-    {
-      int pos, i, nrows = w->current_matrix->nrows;
-      struct glyph_row *row;
-      struct glyph *glyph;
-
-      /* Find the glyph under X/Y.  */
-      glyph = NULL;
-      if (y >= 0 && y < nrows)
+      int vpos = row->y + WINDOW_TOP_EDGE_Y (w);
+      int kstart = start_hpos + WINDOW_LEFT_EDGE_X (w);
+      int nglyphs = end_hpos - start_hpos;
+      int offset = ScreenPrimary + 2*(vpos*screen_size_X + kstart) + 1;
+      int start_offset = offset;
+
+      if (tty->termscript)
+	fprintf (tty->termscript, "\n<MH+ %d-%d:%d>",
+		 kstart, kstart + nglyphs - 1, vpos);
+
+      mouse_off ();
+      IT_set_face (hlinfo->mouse_face_face_id);
+      /* Since we are going to change only the _colors_ of already
+	 displayed text, there's no need to go through all the pain of
+	 generating and encoding the text from the glyphs.  Instead,
+	 we simply poke the attribute byte of each affected position
+	 in video memory with the colors computed by IT_set_face!  */
+      _farsetsel (_dos_ds);
+      while (nglyphs--)
 	{
-	  row = MATRIX_ROW (w->current_matrix, y);
-	  /* Give up if some row before the one we are looking for is
-	     not enabled.  */
-	  for (i = 0; i <= y; i++)
-	    if (!MATRIX_ROW (w->current_matrix, i)->enabled_p)
-	      break;
-	  if (i > y  /* all rows upto and including the one at Y are enabled */
-	      && row->displays_text_p
-	      && x <  window_box_width (w, TEXT_AREA))
-	    {
-	      glyph = row->glyphs[TEXT_AREA];
-	      if (x >= row->used[TEXT_AREA])
-		glyph = NULL;
-	      else
-		{
-		  glyph += x;
-		  if (!BUFFERP (glyph->object))
-		    glyph = NULL;
-		}
-	    }
-	}
-
-      /* Clear mouse face if X/Y not over text.  */
-      if (glyph == NULL)
-	{
-	  clear_mouse_face (dpyinfo);
-	  return;
+	  _farnspokeb (offset, ScreenAttrib);
+	  offset += 2;
 	}
-
-      if (!BUFFERP (glyph->object))
-	abort ();
-      pos = glyph->charpos;
-
-      /* Check for mouse-face and help-echo.  */
-      {
-	Lisp_Object mouse_face, overlay, position, *overlay_vec;
-	int noverlays, obegv, ozv;
-	struct buffer *obuf;
-
-	/* If we get an out-of-range value, return now; avoid an error.  */
-	if (pos > BUF_Z (XBUFFER (w->buffer)))
-	  return;
-
-	/* Make the window's buffer temporarily current for
-	   overlays_at and compute_char_face.  */
-	obuf = current_buffer;
-	current_buffer = XBUFFER (w->buffer);
-	obegv = BEGV;
-	ozv = ZV;
-	BEGV = BEG;
-	ZV = Z;
-
-	/* Is this char mouse-active or does it have help-echo?  */
-	XSETINT (position, pos);
-
-	/* Put all the overlays we want in a vector in overlay_vec. */
-	GET_OVERLAYS_AT (pos, overlay_vec, noverlays, NULL, 0);
-	/* Sort overlays into increasing priority order.  */
-	noverlays = sort_overlays (overlay_vec, noverlays, w);
-
-	/* Check mouse-face highlighting.  */
-	if (! (EQ (window, dpyinfo->mouse_face_window)
-	       && y >= dpyinfo->mouse_face_beg_row
-	       && y <= dpyinfo->mouse_face_end_row
-	       && (y > dpyinfo->mouse_face_beg_row
-		   || x >= dpyinfo->mouse_face_beg_col)
-	       && (y < dpyinfo->mouse_face_end_row
-		   || x < dpyinfo->mouse_face_end_col
-		   || dpyinfo->mouse_face_past_end)))
-	  {
-	    /* Clear the display of the old active region, if any.  */
-	    clear_mouse_face (dpyinfo);
-
-	    /* Find highest priority overlay that has a mouse-face prop.  */
-	    overlay = Qnil;
-	    for (i = noverlays - 1; i >= 0; --i)
-	      {
-		mouse_face = Foverlay_get (overlay_vec[i], Qmouse_face);
-		if (!NILP (mouse_face))
-		  {
-		    overlay = overlay_vec[i];
-		    break;
-		  }
-	      }
-
-	    /* If no overlay applies, get a text property.  */
-	    if (NILP (overlay))
-	      mouse_face = Fget_text_property (position, Qmouse_face,
-					       w->buffer);
-
-	    /* Handle the overlay case.  */
-	    if (! NILP (overlay))
-	      {
-		/* Find the range of text around this char that
-		   should be active.  */
-		Lisp_Object before, after;
-		EMACS_INT ignore;
-
-		before = Foverlay_start (overlay);
-		after = Foverlay_end (overlay);
-		/* Record this as the current active region.  */
-		fast_find_position (w, XFASTINT (before),
-				    &dpyinfo->mouse_face_beg_col,
-				    &dpyinfo->mouse_face_beg_row);
-		dpyinfo->mouse_face_past_end
-		  = !fast_find_position (w, XFASTINT (after),
-					 &dpyinfo->mouse_face_end_col,
-					 &dpyinfo->mouse_face_end_row);
-		dpyinfo->mouse_face_window = window;
-		dpyinfo->mouse_face_face_id
-		  = face_at_buffer_position (w, pos, 0, 0,
-					     &ignore, pos + 1,
-					     !dpyinfo->mouse_face_hidden,
-					     -1);
-
-		/* Display it as active.  */
-		show_mouse_face (dpyinfo, 1);
-	      }
-	    /* Handle the text property case.  */
-	    else if (! NILP (mouse_face))
-	      {
-		/* Find the range of text around this char that
-		   should be active.  */
-		Lisp_Object before, after, beginning, end;
-		EMACS_INT ignore;
-
-		beginning = Fmarker_position (w->start);
-		XSETINT (end, (BUF_Z (XBUFFER (w->buffer))
-			       - XFASTINT (w->window_end_pos)));
-		before
-		  = Fprevious_single_property_change (make_number (pos + 1),
-						      Qmouse_face,
-						      w->buffer, beginning);
-		after
-		  = Fnext_single_property_change (position, Qmouse_face,
-						  w->buffer, end);
-		/* Record this as the current active region.  */
-		fast_find_position (w, XFASTINT (before),
-				    &dpyinfo->mouse_face_beg_col,
-				    &dpyinfo->mouse_face_beg_row);
-		dpyinfo->mouse_face_past_end
-		  = !fast_find_position (w, XFASTINT (after),
-					 &dpyinfo->mouse_face_end_col,
-					 &dpyinfo->mouse_face_end_row);
-		dpyinfo->mouse_face_window = window;
-		dpyinfo->mouse_face_face_id
-		  = face_at_buffer_position (w, pos, 0, 0,
-					     &ignore, pos + 1,
-					     !dpyinfo->mouse_face_hidden,
-					     -1);
-
-		/* Display it as active.  */
-		show_mouse_face (dpyinfo, 1);
-	      }
-	  }
-
-	/* Look for a `help-echo' property.  */
-	{
-	  Lisp_Object help;
-
-	  /* Check overlays first.  */
-	  help = Qnil;
-	  for (i = noverlays - 1; i >= 0 && NILP (help); --i)
-	    {
-	      overlay = overlay_vec[i];
-	      help = Foverlay_get (overlay, Qhelp_echo);
-	    }
-
-	  if (!NILP (help))
-	    {
-	      help_echo_string = help;
-	      help_echo_window = window;
-	      help_echo_object = overlay;
-	      help_echo_pos = pos;
-	    }
-	  /* Try text properties.  */
-	  else if (NILP (help)
-		   && ((STRINGP (glyph->object)
-			&& glyph->charpos >= 0
-			&& glyph->charpos < SCHARS (glyph->object))
-		       || (BUFFERP (glyph->object)
-			   && glyph->charpos >= BEGV
-			   && glyph->charpos < ZV)))
-	    {
-	      help = Fget_text_property (make_number (glyph->charpos),
-					 Qhelp_echo, glyph->object);
-	      if (!NILP (help))
-		{
-		  help_echo_string = help;
-		  help_echo_window = window;
-		  help_echo_object = glyph->object;
-		  help_echo_pos = glyph->charpos;
-		}
-	    }
-	}
-
-	BEGV = obegv;
-	ZV = ozv;
-	current_buffer = obuf;
-      }
+      if (screen_virtual_segment)
+	dosv_refresh_virtual_screen (start_offset, end_hpos - start_hpos);
+      mouse_on ();
+    }
+  else if (hl == DRAW_NORMAL_TEXT)
+    {
+      /* We are removing a previously-drawn mouse highlight.  The
+	 safest way to do so is to redraw the glyphs anew, since all
+	 kinds of faces and display tables could have changed behind
+	 our back.  */
+      int nglyphs = end_hpos - start_hpos;
+      int save_x = new_pos_X, save_y = new_pos_Y;
+
+      if (end_hpos >= row->used[TEXT_AREA])
+	nglyphs = row->used[TEXT_AREA] - start_hpos;
+
+      /* IT_write_glyphs writes at cursor position, so we need to
+	 temporarily move cursor coordinates to the beginning of
+	 the highlight region.  */
+      new_pos_X = start_hpos + WINDOW_LEFT_EDGE_X (w);
+      new_pos_Y = row->y + WINDOW_TOP_EDGE_Y (w);
+
+      if (tty->termscript)
+	fprintf (tty->termscript, "<MH- %d-%d:%d>",
+		 new_pos_X, new_pos_X + nglyphs - 1, new_pos_Y);
+      IT_write_glyphs (f, row->glyphs[TEXT_AREA] + start_hpos, nglyphs);
+      if (tty->termscript)
+	fputs ("\n", tty->termscript);
+      new_pos_X = save_x;
+      new_pos_Y = save_y;
     }
 }
 
@@ -1689,7 +1217,8 @@
 IT_update_begin (struct frame *f)
 {
   struct tty_display_info *display_info = FRAME_X_DISPLAY_INFO (f);
-  struct frame *mouse_face_frame = display_info->mouse_face_mouse_frame;
+  Mouse_HLInfo *hlinfo = &display_info->mouse_highlight;
+  struct frame *mouse_face_frame = hlinfo->mouse_face_mouse_frame;
 
   if (display_info->termscript)
     fprintf (display_info->termscript, "\n\n<UPDATE_BEGIN");
@@ -1699,28 +1228,28 @@
   if (f && f == mouse_face_frame)
     {
       /* Don't do highlighting for mouse motion during the update.  */
-      display_info->mouse_face_defer = 1;
+      hlinfo->mouse_face_defer = 1;
 
       /* If F needs to be redrawn, simply forget about any prior mouse
 	 highlighting.  */
       if (FRAME_GARBAGED_P (f))
-	display_info->mouse_face_window = Qnil;
+	hlinfo->mouse_face_window = Qnil;
 
       /* Can we tell that this update does not affect the window
 	 where the mouse highlight is?  If so, no need to turn off.
 	 Likewise, don't do anything if none of the enabled rows
 	 contains glyphs highlighted in mouse face.  */
-      if (!NILP (display_info->mouse_face_window)
-	  && WINDOWP (display_info->mouse_face_window))
+      if (!NILP (hlinfo->mouse_face_window)
+	  && WINDOWP (hlinfo->mouse_face_window))
 	{
-	  struct window *w = XWINDOW (display_info->mouse_face_window);
+	  struct window *w = XWINDOW (hlinfo->mouse_face_window);
 	  int i;
 
 	  /* If the mouse highlight is in the window that was deleted
 	     (e.g., if it was popped by completion), clear highlight
 	     unconditionally.  */
 	  if (NILP (w->buffer))
-	    display_info->mouse_face_window = Qnil;
+	    hlinfo->mouse_face_window = Qnil;
 	  else
 	    {
 	      for (i = 0; i < w->desired_matrix->nrows; ++i)
@@ -1730,18 +1259,18 @@
 	    }
 
 	  if (NILP (w->buffer) || i < w->desired_matrix->nrows)
-	    clear_mouse_face (display_info);
+	    clear_mouse_face (hlinfo);
 	}
     }
   else if (mouse_face_frame && !FRAME_LIVE_P (mouse_face_frame))
     {
       /* If the frame with mouse highlight was deleted, invalidate the
 	 highlight info.  */
-      display_info->mouse_face_beg_row = display_info->mouse_face_beg_col = -1;
-      display_info->mouse_face_end_row = display_info->mouse_face_end_col = -1;
-      display_info->mouse_face_window = Qnil;
-      display_info->mouse_face_deferred_gc = 0;
-      display_info->mouse_face_mouse_frame = NULL;
+      hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
+      hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
+      hlinfo->mouse_face_window = Qnil;
+      hlinfo->mouse_face_deferred_gc = 0;
+      hlinfo->mouse_face_mouse_frame = NULL;
     }
 
   UNBLOCK_INPUT;
@@ -1754,25 +1283,25 @@
 
   if (dpyinfo->termscript)
     fprintf (dpyinfo->termscript, "\n<UPDATE_END\n");
-  dpyinfo->mouse_face_defer = 0;
+  dpyinfo->mouse_highlight.mouse_face_defer = 0;
 }
 
 static void
 IT_frame_up_to_date (struct frame *f)
 {
-  struct tty_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
+  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
   Lisp_Object new_cursor, frame_desired_cursor;
   struct window *sw;
 
-  if (dpyinfo->mouse_face_deferred_gc
-      || (f && f == dpyinfo->mouse_face_mouse_frame))
+  if (hlinfo->mouse_face_deferred_gc
+      || (f && f == hlinfo->mouse_face_mouse_frame))
     {
       BLOCK_INPUT;
-      if (dpyinfo->mouse_face_mouse_frame)
-	IT_note_mouse_highlight (dpyinfo->mouse_face_mouse_frame,
-				 dpyinfo->mouse_face_mouse_x,
-				 dpyinfo->mouse_face_mouse_y);
-      dpyinfo->mouse_face_deferred_gc = 0;
+      if (hlinfo->mouse_face_mouse_frame)
+	note_mouse_highlight (hlinfo->mouse_face_mouse_frame,
+			      hlinfo->mouse_face_mouse_x,
+			      hlinfo->mouse_face_mouse_y);
+      hlinfo->mouse_face_deferred_gc = 0;
       UNBLOCK_INPUT;
     }
 
@@ -2317,18 +1846,18 @@
 	  if (colors[1] >= 0 && colors[1] < 16)
 	    FRAME_BACKGROUND_PIXEL (SELECTED_FRAME ()) = colors[1];
 	}
-      the_only_display_info.mouse_face_mouse_frame = NULL;
-      the_only_display_info.mouse_face_deferred_gc = 0;
-      the_only_display_info.mouse_face_beg_row =
-	the_only_display_info.mouse_face_beg_col = -1;
-      the_only_display_info.mouse_face_end_row =
-	the_only_display_info.mouse_face_end_col = -1;
-      the_only_display_info.mouse_face_face_id = DEFAULT_FACE_ID;
-      the_only_display_info.mouse_face_window = Qnil;
-      the_only_display_info.mouse_face_mouse_x =
-	the_only_display_info.mouse_face_mouse_y = 0;
-      the_only_display_info.mouse_face_defer = 0;
-      the_only_display_info.mouse_face_hidden = 0;
+      the_only_display_info.mouse_highlight.mouse_face_mouse_frame = NULL;
+      the_only_display_info.mouse_highlight.mouse_face_deferred_gc = 0;
+      the_only_display_info.mouse_highlight.mouse_face_beg_row =
+	the_only_display_info.mouse_highlight.mouse_face_beg_col = -1;
+      the_only_display_info.mouse_highlight.mouse_face_end_row =
+	the_only_display_info.mouse_highlight.mouse_face_end_col = -1;
+      the_only_display_info.mouse_highlight.mouse_face_face_id = DEFAULT_FACE_ID;
+      the_only_display_info.mouse_highlight.mouse_face_window = Qnil;
+      the_only_display_info.mouse_highlight.mouse_face_mouse_x =
+	the_only_display_info.mouse_highlight.mouse_face_mouse_y = 0;
+      the_only_display_info.mouse_highlight.mouse_face_defer = 0;
+      the_only_display_info.mouse_highlight.mouse_face_hidden = 0;
 
       if (have_mouse)	/* detected in dos_ttraw, which see */
 	{
@@ -2916,7 +2445,7 @@
 {
   struct input_event event;
   union REGS regs;
-  struct tty_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (SELECTED_FRAME());
+  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (SELECTED_FRAME());
   EVENT_INIT (event);
 
 #ifndef HAVE_X_WINDOWS
@@ -3126,10 +2655,10 @@
       if (code == 0)
 	continue;
 
-      if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight))
+      if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight))
 	{
-	  clear_mouse_face (dpyinfo);
-	  dpyinfo->mouse_face_hidden = 1;
+	  clear_mouse_face (hlinfo);
+	  hlinfo->mouse_face_hidden = 1;
 	}
 
       if (code >= 0x100)
@@ -3157,10 +2686,10 @@
          might need to update mouse highlight.  */
       if (mouse_last_x != mouse_prev_x || mouse_last_y != mouse_prev_y)
 	{
-	  if (dpyinfo->mouse_face_hidden)
+	  if (hlinfo->mouse_face_hidden)
 	    {
-	      dpyinfo->mouse_face_hidden = 0;
-	      clear_mouse_face (dpyinfo);
+	      hlinfo->mouse_face_hidden = 0;
+	      clear_mouse_face (hlinfo);
 	    }
 
 	  /* Generate SELECT_WINDOW_EVENTs when needed.  */
@@ -3192,8 +2721,7 @@
 	  previous_help_echo_string = help_echo_string;
 	  help_echo_string = help_echo_object = help_echo_window = Qnil;
 	  help_echo_pos = -1;
-	  IT_note_mouse_highlight (SELECTED_FRAME(),
-				   mouse_last_x, mouse_last_y);
+	  note_mouse_highlight (SELECTED_FRAME(), mouse_last_x, mouse_last_y);
 	  /* If the contents of the global variable help_echo has
 	     changed, generate a HELP_EVENT.  */
 	  if (!NILP (help_echo_string) || !NILP (previous_help_echo_string))
--- a/src/msdos.h	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/msdos.h	Mon Nov 08 14:19:54 2010 +0900
@@ -34,6 +34,7 @@
 char *rootrelativepath (char *);
 void init_environment (int, char **, int);
 void internal_terminal_init (void);
+void initialize_msdos_display (struct terminal *);
 
 extern int have_mouse;
 void mouse_init (void);
--- a/src/nsfns.m	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/nsfns.m	Mon Nov 08 14:19:54 2010 +0900
@@ -1,6 +1,7 @@
 /* Functions for the NeXT/Open/GNUstep and MacOSX window system.
-   Copyright (C) 1989, 1992, 1993, 1994, 2005, 2006, 2008, 2009, 2010
-     Free Software Foundation, Inc.
+
+Copyright (C) 1989, 1992, 1993, 1994, 2005, 2006, 2008, 2009, 2010
+  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -1697,7 +1698,7 @@
 
 DEFUN ("x-display-save-under", Fx_display_save_under,
        Sx_display_save_under, 0, 1, 0,
-       doc: /* Non-nil if the Nextstep display server supports the save-under feature.
+       doc: /* Return t if DISPLAY supports the save-under feature.
 The optional argument DISPLAY specifies which display to ask about.
 DISPLAY should be a frame, the display name as a string, or a terminal ID.
 If omitted or nil, the selected frame's display is used.  */)
@@ -1722,9 +1723,12 @@
 
 DEFUN ("x-open-connection", Fx_open_connection, Sx_open_connection,
        1, 3, 0,
-       doc: /* Open a connection to a Nextstep display server.
+       doc: /* Open a connection to a display server.
 DISPLAY is the name of the display to connect to.
-Optional arguments XRM-STRING and MUST-SUCCEED are currently ignored.  */)
+Optional second arg XRM-STRING is a string of resources in xrdb format.
+If the optional third arg MUST-SUCCEED is non-nil,
+terminate Emacs if we can't open the connection.
+\(In the Nextstep version, the last two arguments are currently ignored.)  */)
      (Lisp_Object display, Lisp_Object resource_string, Lisp_Object must_succeed)
 {
   struct ns_display_info *dpyinfo;
@@ -2201,8 +2205,8 @@
 
 
 DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
-       doc: /* Return t if the current Nextstep display supports the color COLOR.
-The optional argument FRAME is currently ignored.  */)
+       doc: /* Internal function called by `color-defined-p', which see.
+\(Note that the Nextstep version of this function ignores FRAME.)  */)
      (Lisp_Object color, Lisp_Object frame)
 {
   NSColor * col;
@@ -2233,10 +2237,7 @@
 
 
 DEFUN ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0,
-       doc: /* Return t if the Nextstep display supports color.
-The optional argument DISPLAY specifies which display to ask about.
-DISPLAY should be either a frame, a display name (a string), or terminal ID.
-If omitted or nil, that stands for the selected frame's display.  */)
+       doc: /* Internal function called by `display-color-p', which see.  */)
      (Lisp_Object display)
 {
   NSWindowDepth depth;
@@ -2430,6 +2431,8 @@
        doc: /* Show STRING in a \"tooltip\" window on frame FRAME.
 A tooltip window is a small window displaying a string.
 
+This is an internal function; Lisp code should call `tooltip-show'.
+
 FRAME nil or omitted means use the selected frame.
 
 PARMS is an optional list of frame parameters which can be used to
@@ -2675,4 +2678,3 @@
 
 }
 
-// arch-tag: dc2a3f74-1123-4daa-8eed-fb78db6a5642
--- a/src/nsfont.m	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/nsfont.m	Mon Nov 08 14:19:54 2010 +0900
@@ -37,6 +37,7 @@
 #include "frame.h"
 #include "character.h"
 #include "font.h"
+#include "termchar.h"
 
 /* TODO: Drop once we can assume gnustep-gui 0.17.1. */
 #ifdef NS_IMPL_GNUSTEP
@@ -1040,8 +1041,7 @@
       face = s->face;
       break;
     case NS_DUMPGLYPH_MOUSEFACE:
-      face = FACE_FROM_ID (s->f,
-                           FRAME_NS_DISPLAY_INFO (s->f)->mouse_face_face_id);
+      face = FACE_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id);
       if (!face)
         face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
       break;
@@ -1211,7 +1211,6 @@
     DPSstroke (context);
 
     DPSgrestore (context);
-    return to-from;
   }
 
 #else  /* NS_IMPL_COCOA */
@@ -1280,10 +1279,9 @@
       }
 
     CGContextRestoreGState (gcontext);
-    return;
   }
 #endif  /* NS_IMPL_COCOA */
-
+  return to-from;
 }
 
 
--- a/src/nsimage.m	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/nsimage.m	Mon Nov 08 14:19:54 2010 +0900
@@ -336,7 +336,7 @@
   NSColor *rgbColor;
 
   if (bmRep == nil || color == nil)
-    return;
+    return self;
 
   if ([color colorSpaceName] != NSCalibratedRGBColorSpace)
     rgbColor = [color colorUsingColorSpaceName: NSCalibratedRGBColorSpace];
@@ -361,6 +361,8 @@
           planes[2][i] = bb;
         }
   }
+
+  return self;
 }
 
 
--- a/src/nsterm.h	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/nsterm.h	Mon Nov 08 14:19:54 2010 +0900
@@ -492,21 +492,9 @@
   /* The cursor to use for vertical scroll bars. */
   Cursor vertical_scroll_bar_cursor;
 
-  /* most mouse face stuff moved in here as of 21+ (and reasonably so) */
-  int mouse_face_beg_row, mouse_face_beg_col;
-  int mouse_face_end_row, mouse_face_end_col;
-  int mouse_face_beg_x, mouse_face_beg_y;
-  int mouse_face_end_x, mouse_face_end_y;
-  int mouse_face_past_end;
-  Lisp_Object mouse_face_window;
-  int mouse_face_face_id;
-  int mouse_face_deferred_gc;
-  Lisp_Object mouse_face_overlay;
-  FRAME_PTR mouse_face_mouse_frame;
-  int mouse_face_mouse_x, mouse_face_mouse_y;
-  int mouse_face_defer;
-  int mouse_face_hidden;
-  int mouse_face_image_state;
+  /* Information about the range of text currently shown in
+     mouse-face.  */
+  Mouse_HLInfo mouse_highlight;
 
   struct frame *x_highlight_frame;
   struct frame *x_focus_frame;
--- a/src/nsterm.m	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/nsterm.m	Mon Nov 08 14:19:54 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. */
@@ -553,7 +553,7 @@
    -------------------------------------------------------------------------- */
 {
   struct frame *f = XFRAME (WINDOW_FRAME (w));
-  struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f);
+ Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
   NSTRACE (ns_update_window_begin);
 
   updated_window = w;
@@ -561,15 +561,15 @@
 
   BLOCK_INPUT;
 
-  if (f == dpyinfo->mouse_face_mouse_frame)
+  if (f == hlinfo->mouse_face_mouse_frame)
     {
       /* Don't do highlighting for mouse motion during the update.  */
-      dpyinfo->mouse_face_defer = 1;
+      hlinfo->mouse_face_defer = 1;
 
         /* If the frame needs to be redrawn,
            simply forget about any prior mouse highlighting.  */
       if (FRAME_GARBAGED_P (f))
-        dpyinfo->mouse_face_window = Qnil;
+        hlinfo->mouse_face_window = Qnil;
 
       /* (further code for mouse faces ifdef'd out in other terms elided) */
     }
@@ -586,7 +586,7 @@
    external (RIF) call; for one window called before update_end
    -------------------------------------------------------------------------- */
 {
-  struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (XFRAME (w->frame));
+  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (XFRAME (w->frame));
 
   /* note: this fn is nearly identical in all terms */
   if (!w->pseudo_window_p)
@@ -608,9 +608,9 @@
      frame_up_to_date to redisplay the mouse highlight.  */
   if (mouse_face_overwritten_p)
     {
-      dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1;
-      dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
-      dpyinfo->mouse_face_window = Qnil;
+      hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
+      hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
+      hlinfo->mouse_face_window = Qnil;
     }
 
   updated_window = NULL;
@@ -627,8 +627,8 @@
 {
   NSView *view = FRAME_NS_VIEW (f);
 
-/*   if (f == FRAME_NS_DISPLAY_INFO (f)->mouse_face_mouse_frame) */
-    FRAME_NS_DISPLAY_INFO (f)->mouse_face_defer = 0;
+/*   if (f == MOUSE_HL_INFO (f)->mouse_face_mouse_frame) */
+    MOUSE_HL_INFO (f)->mouse_face_defer = 0;
 
   BLOCK_INPUT;
 
@@ -1032,6 +1032,7 @@
 {
   NSView *view = FRAME_NS_VIEW (f);
   struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f);
+  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
   NSTRACE (x_destroy_window);
   check_ns ();
 
@@ -1048,13 +1049,13 @@
     dpyinfo->x_focus_frame = 0;
   if (f == dpyinfo->x_highlight_frame)
     dpyinfo->x_highlight_frame = 0;
-  if (f == dpyinfo->mouse_face_mouse_frame)
+  if (f == hlinfo->mouse_face_mouse_frame)
     {
-      dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1;
-      dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
-      dpyinfo->mouse_face_window = Qnil;
-      dpyinfo->mouse_face_deferred_gc = 0;
-      dpyinfo->mouse_face_mouse_frame = 0;
+      hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
+      hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
+      hlinfo->mouse_face_window = Qnil;
+      hlinfo->mouse_face_deferred_gc = 0;
+      hlinfo->mouse_face_mouse_frame = 0;
     }
 
   xfree (f->output_data.ns);
@@ -1772,18 +1773,18 @@
 
   if (FRAME_NS_P (f))
     {
-      struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f);
-      if ((dpyinfo->mouse_face_deferred_gc||f ==dpyinfo->mouse_face_mouse_frame)
-      /*&& dpyinfo->mouse_face_mouse_frame*/)
+      Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
+      if ((hlinfo->mouse_face_deferred_gc || f ==hlinfo->mouse_face_mouse_frame)
+      /*&& hlinfo->mouse_face_mouse_frame*/)
         {
           BLOCK_INPUT;
-         ns_update_begin(f);
-          if (dpyinfo->mouse_face_mouse_frame)
-            note_mouse_highlight (dpyinfo->mouse_face_mouse_frame,
-                                  dpyinfo->mouse_face_mouse_x,
-                                  dpyinfo->mouse_face_mouse_y);
-          dpyinfo->mouse_face_deferred_gc = 0;
-         ns_update_end(f);
+	  ns_update_begin(f);
+          if (hlinfo->mouse_face_mouse_frame)
+            note_mouse_highlight (hlinfo->mouse_face_mouse_frame,
+                                  hlinfo->mouse_face_mouse_x,
+                                  hlinfo->mouse_face_mouse_y);
+          hlinfo->mouse_face_deferred_gc = 0;
+	  ns_update_end(f);
           UNBLOCK_INPUT;
         }
     }
@@ -2595,8 +2596,7 @@
 
   if (s->hl == DRAW_MOUSE_FACE)
     {
-      face = FACE_FROM_ID
-        (s->f, FRAME_NS_DISPLAY_INFO (s->f)->mouse_face_face_id);
+      face = FACE_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id);
       if (!face)
         face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
     }
@@ -2663,8 +2663,8 @@
           struct face *face;
           if (s->hl == DRAW_MOUSE_FACE)
             {
-              face = FACE_FROM_ID
-                (s->f, FRAME_NS_DISPLAY_INFO (s->f)->mouse_face_face_id);
+              face = FACE_FROM_ID (s->f,
+				   MOUSE_HL_INFO (s->f)->mouse_face_face_id);
               if (!face)
                 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
             }
@@ -2749,8 +2749,7 @@
      with its background color), we must clear just the image area. */
   if (s->hl == DRAW_MOUSE_FACE)
     {
-      face = FACE_FROM_ID
-       (s->f, FRAME_NS_DISPLAY_INFO (s->f)->mouse_face_face_id);
+      face = FACE_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id);
       if (!face)
        face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
     }
@@ -2873,8 +2872,7 @@
 
       if (s->hl == DRAW_MOUSE_FACE)
        {
-         face = FACE_FROM_ID
-           (s->f, FRAME_NS_DISPLAY_INFO (s->f)->mouse_face_face_id);
+         face = FACE_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id);
          if (!face)
            face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
        }
@@ -2983,6 +2981,22 @@
       ns_unfocus (s->f);
       break;
 
+    case GLYPHLESS_GLYPH:
+      n = ns_get_glyph_string_clip_rect (s, r);
+      ns_focus (s->f, r, n);
+
+      if (s->for_overlaps || (s->cmp_from > 0
+			      && ! s->first_glyph->u.cmp.automatic))
+        s->background_filled_p = 1;
+      else
+        ns_maybe_dumpglyphs_background
+          (s, s->first_glyph->type == COMPOSITE_GLYPH);
+      /* ... */ 
+      /* Not yet implemented.  */
+      /* ... */ 
+      ns_unfocus (s->f);
+      break;
+
     default:
       abort ();
     }
@@ -3529,6 +3543,7 @@
 {
     NSScreen *screen = [NSScreen mainScreen];
     NSWindowDepth depth = [screen depth];
+    Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight;
 
     dpyinfo->resx = 72.27; /* used 75.0, but this makes pt == pixel, expected */
     dpyinfo->resy = 72.27;
@@ -3543,16 +3558,16 @@
     dpyinfo->color_table->colors = NULL;
     dpyinfo->root_window = 42; /* a placeholder.. */
 
-    dpyinfo->mouse_face_mouse_frame = NULL;
-    dpyinfo->mouse_face_deferred_gc = 0;
-    dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1;
-    dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
-    dpyinfo->mouse_face_face_id = DEFAULT_FACE_ID;
-    dpyinfo->mouse_face_window = dpyinfo->mouse_face_overlay = Qnil;
-    dpyinfo->mouse_face_hidden = 0;
-
-    dpyinfo->mouse_face_mouse_x = dpyinfo->mouse_face_mouse_y = 0;
-    dpyinfo->mouse_face_defer = 0;
+    hlinfo->mouse_face_mouse_frame = NULL;
+    hlinfo->mouse_face_deferred_gc = 0;
+    hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
+    hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
+    hlinfo->mouse_face_face_id = DEFAULT_FACE_ID;
+    hlinfo->mouse_face_window = hlinfo->mouse_face_overlay = Qnil;
+    hlinfo->mouse_face_hidden = 0;
+
+    hlinfo->mouse_face_mouse_x = hlinfo->mouse_face_mouse_y = 0;
+    hlinfo->mouse_face_defer = 0;
 
     dpyinfo->x_highlight_frame = dpyinfo->x_focus_frame = NULL;
 
@@ -4335,7 +4350,7 @@
 
 - (void)keyDown: (NSEvent *)theEvent
 {
-  struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (emacsframe);
+  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (emacsframe);
   int code;
   unsigned fnKeysym = 0;
   int flags;
@@ -4373,10 +4388,10 @@
 
   [NSCursor setHiddenUntilMouseMoves: YES];
 
-  if (dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight))
+  if (hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight))
     {
-      clear_mouse_face (dpyinfo);
-      dpyinfo->mouse_face_hidden = 1;
+      clear_mouse_face (hlinfo);
+      hlinfo->mouse_face_hidden = 1;
     }
 
   if (!processingCompose)
@@ -4813,7 +4828,7 @@
 /* Tell emacs the mouse has moved. */
 - (void)mouseMoved: (NSEvent *)e
 {
-  struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (emacsframe);
+  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (emacsframe);
   Lisp_Object frame;
 
 //  NSTRACE (mouseMoved);
@@ -4823,10 +4838,10 @@
     = [self convertPoint: [e locationInWindow] fromView: nil];
 
   /* update any mouse face */
-  if (dpyinfo->mouse_face_hidden)
+  if (hlinfo->mouse_face_hidden)
     {
-      dpyinfo->mouse_face_hidden = 0;
-      clear_mouse_face (dpyinfo);
+      hlinfo->mouse_face_hidden = 0;
+      clear_mouse_face (hlinfo);
     }
 
   /* tooltip handling */
@@ -5292,20 +5307,19 @@
 {
   NSPoint p = [self convertPoint: [theEvent locationInWindow] fromView: nil];
   NSRect r;
-  struct ns_display_info *dpyinfo
-    = emacsframe ? FRAME_NS_DISPLAY_INFO (emacsframe) : NULL;
+  Mouse_HLInfo *hlinfo = emacsframe ? MOUSE_HL_INFO (emacsframe) : NULL;
 
   NSTRACE (mouseExited);
 
-  if (dpyinfo || !emacsframe)
+  if (!hlinfo)
     return;
 
   last_mouse_movement_time = EV_TIMESTAMP (theEvent);
 
-  if (emacsframe == dpyinfo->mouse_face_mouse_frame)
+  if (emacsframe == hlinfo->mouse_face_mouse_frame)
     {
-      clear_mouse_face (dpyinfo);
-      dpyinfo->mouse_face_mouse_frame = 0;
+      clear_mouse_face (hlinfo);
+      hlinfo->mouse_face_mouse_frame = 0;
     }
 }
 
@@ -5420,7 +5434,7 @@
   NSTRACE (performDragOperation);
 
   if (!emacs_event)
-    return;
+    return NO;
 
   position = [self convertPoint: [sender draggingLocation] fromView: nil];
   x = lrint (position.x);  y = lrint (position.y);
--- a/src/print.c	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/print.c	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/regex.c	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/s/cygwin.h	Mon Nov 08 14:19:54 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/term.c	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/term.c	Mon Nov 08 14:19:54 2010 +0900
@@ -184,24 +184,10 @@
 #ifdef HAVE_GPM
 #include <sys/fcntl.h>
 
-static void term_clear_mouse_face (void);
-static void term_mouse_highlight (struct frame *f, int x, int y);
-
 /* The device for which we have enabled gpm support (or NULL).  */
 struct tty_display_info *gpm_tty = NULL;
 
-/* These variables describe the range of text currently shown in its
-   mouse-face, together with the window they apply to.  As long as
-   the mouse stays within this range, we need not redraw anything on
-   its account.  Rows and columns are glyph matrix positions in
-   MOUSE_FACE_WINDOW.  */
-static int mouse_face_beg_row, mouse_face_beg_col;
-static int mouse_face_end_row, mouse_face_end_col;
-static int mouse_face_past_end;
-static Lisp_Object mouse_face_window;
-static int mouse_face_face_id;
-
-static int pos_x, pos_y;
+/* Last recorded mouse coordinates.  */
 static int last_mouse_x, last_mouse_y;
 #endif /* HAVE_GPM */
 
@@ -1501,6 +1487,8 @@
 static void produce_stretch_glyph (struct it *);
 static void append_composite_glyph (struct it *);
 static void produce_composite_glyph (struct it *);
+static void append_glyphless_glyph (struct it *, int, char *);
+static void produce_glyphless_glyph (struct it *, int, Lisp_Object);
 
 /* Append glyphs to IT's glyph_row.  Called from produce_glyphs for
    terminal frames if IT->glyph_row != NULL.  IT->char_to_display is
@@ -1609,6 +1597,12 @@
       goto done;
     }
 
+  if (it->what == IT_GLYPHLESS)
+    {
+      produce_glyphless_glyph (it, 0, Qnil);
+      goto done;
+    }
+
   if (it->char_to_display >= 040 && it->char_to_display < 0177)
     {
       it->pixel_width = it->nglyphs = 1;
@@ -1660,11 +1654,22 @@
     }
   else
     {
-      it->pixel_width = CHAR_WIDTH (it->char_to_display);
-      it->nglyphs = it->pixel_width;
-
-      if (it->glyph_row)
-	append_glyph (it);
+      Lisp_Object charset_list = FRAME_TERMINAL (it->f)->charset_list;
+
+      if (char_charset (it->char_to_display, charset_list, NULL))
+	{
+	  it->pixel_width = CHAR_WIDTH (it->char_to_display);
+	  it->nglyphs = it->pixel_width;
+	  if (it->glyph_row)
+	    append_glyph (it);
+	}
+      else
+	{
+	  Lisp_Object acronym = lookup_glyphless_char_display (-1, it);
+
+	  xassert (it->what == IT_GLYPHLESS);
+	  produce_glyphless_glyph (it, 1, acronym);
+	}
     }
 
  done:
@@ -1844,6 +1849,156 @@
 }
 
 
+/* Append a glyph for a glyphless character to IT->glyph_row.  FACE_ID
+   is a face ID to be used for the glyph.  What actually appended are
+   glyphs of type CHAR_GLYPH of which characters are in STR
+   (it->nglyphs bytes).  */
+
+static void
+append_glyphless_glyph (struct it *it, int face_id, char *str)
+{
+  struct glyph *glyph, *end;
+  int i;
+
+  xassert (it->glyph_row);
+  glyph = it->glyph_row->glyphs[it->area] + it->glyph_row->used[it->area];
+  end = it->glyph_row->glyphs[1 + it->area];
+
+  /* If the glyph row is reversed, we need to prepend the glyph rather
+     than append it.  */
+  if (it->glyph_row->reversed_p && it->area == TEXT_AREA)
+    {
+      struct glyph *g;
+      int move_by = it->pixel_width;
+
+      /* Make room for the new glyphs.  */
+      if (move_by > end - glyph) /* don't overstep end of this area */
+	move_by = end - glyph;
+      for (g = glyph - 1; g >= it->glyph_row->glyphs[it->area]; g--)
+	g[move_by] = *g;
+      glyph = it->glyph_row->glyphs[it->area];
+      end = glyph + move_by;
+    }
+
+  if (glyph >= end)
+    return;
+  glyph->type = CHAR_GLYPH;
+  glyph->pixel_width = 1;
+  glyph->face_id = face_id;
+  glyph->padding_p = 0;
+  glyph->charpos = CHARPOS (it->position);
+  glyph->object = it->object;
+  if (it->bidi_p)
+    {
+      glyph->resolved_level = it->bidi_it.resolved_level;
+      if ((it->bidi_it.type & 7) != it->bidi_it.type)
+	abort ();
+      glyph->bidi_type = it->bidi_it.type;
+    }
+  else
+    {
+      glyph->resolved_level = 0;
+      glyph->bidi_type = UNKNOWN_BT;
+    }
+
+  /* BIDI Note: we put the glyphs of characters left to right, even in
+     the REVERSED_P case because we write to the terminal
+     left-to-right.  */
+  for (i = 0; i < it->nglyphs && glyph < end; ++i)
+    {
+      if (i > 0)
+	glyph[0] = glyph[-1];
+      glyph->u.ch = str[i];
+      ++it->glyph_row->used[it->area];
+      ++glyph;
+    }
+}
+
+/* Declared in xdisp.c */
+extern struct frame *last_glyphless_glyph_frame;
+extern unsigned last_glyphless_glyph_face_id;
+extern int last_glyphless_glyph_merged_face_id;
+extern Lisp_Object Qglyphless_char;
+
+/* Produce glyphs for a glyphless character for iterator IT.
+   IT->glyphless_method specifies which method to use for displaying
+   the character.  See the description of enum
+   glyphless_display_method in dispextern.h for the detail.
+
+   FOR_NO_FONT is nonzero if and only if this is for a character that
+   is not supproted by the coding system of the terminal.  ACRONYM, if
+   non-nil, is an acronym string for the character.
+
+   The glyphs actually produced are of type CHAR_GLYPH.  */
+
+static void
+produce_glyphless_glyph (struct it *it, int for_no_font, Lisp_Object acronym)
+{
+  int face_id;
+  int width, len;
+  char buf[9], *str = "    ";
+
+  /* Get a face ID for the glyph by utilizing a cache (the same way as
+     doen for `escape-glyph' in get_next_display_element).  */
+  if (it->f == last_glyphless_glyph_frame
+      && it->face_id == last_glyphless_glyph_face_id)
+    {
+      face_id = last_glyphless_glyph_merged_face_id;
+    }
+  else
+    {
+      /* Merge the `glyphless-char' face into the current face.  */
+      face_id = merge_faces (it->f, Qglyphless_char, 0, it->face_id);
+      last_glyphless_glyph_frame = it->f;
+      last_glyphless_glyph_face_id = it->face_id;
+      last_glyphless_glyph_merged_face_id = face_id;
+    }
+
+  if (it->glyphless_method == GLYPHLESS_DISPLAY_THIN_SPACE)
+    {
+      /* As there's no way to produce a thin space, we produce
+	 a space of canonical width..  */
+      len = 1;
+    }
+  else if (it->glyphless_method == GLYPHLESS_DISPLAY_EMPTY_BOX)
+    {
+      len = CHAR_WIDTH (it->c);
+      if (len == 0)
+	len = 1;
+      else if (width > 4)
+	len = 4;
+    }
+  else
+    {
+      if (it->glyphless_method == GLYPHLESS_DISPLAY_ACRONYM)
+	{
+	  if (! STRINGP (acronym) && CHAR_TABLE_P (Vglyphless_char_display))
+	    acronym = CHAR_TABLE_REF (Vglyphless_char_display, it->c);
+	  buf[0] = '[';
+	  str = STRINGP (acronym) ? (char *) SDATA (acronym) : "";
+	  for (len = 0; len < 6 && str[len] && ASCII_BYTE_P (str[len]); len++)
+	    buf[1 + len] = str[len];
+	  buf[1 + len] = ']';
+	  len += 2;
+	}
+      else
+	{
+	  xassert (it->glyphless_method == GLYPHLESS_DISPLAY_HEXA_CODE);
+	  len = (it->c < 0x100 ? sprintf (buf, "U+%02X", it->c)
+		 : it->c < 0x10000 ? sprintf (buf, "U+%04X", it->c)
+		 : it->c <= MAX_UNICODE_CHAR ? sprintf (buf, "U+%06X", it->c)
+		 : sprintf (buf, "E+%06X", it->c));
+	}
+      str = buf;
+    }
+
+  it->pixel_width = len;
+  it->nglyphs = len;
+  if (len > 0 && it->glyph_row)
+    append_glyphless_glyph (it, face_id, str);
+}
+
+
 /* Get information about special display element WHAT in an
    environment described by IT.  WHAT is one of IT_TRUNCATION or
    IT_CONTINUATION.  Maybe produce glyphs for WHAT if IT has a
@@ -2517,416 +2672,36 @@
   last_mouse_y = y;  */
 }
 
-static void
-term_show_mouse_face (enum draw_glyphs_face draw)
-{
-  struct window *w = XWINDOW (mouse_face_window);
-  int save_x, save_y;
-  int i;
-
-  struct frame *f = XFRAME (w->frame);
-  struct tty_display_info *tty = FRAME_TTY (f);
-
-  if (/* If window is in the process of being destroyed, don't bother
-	 to do anything.  */
-      w->current_matrix != NULL
-      /* Recognize when we are called to operate on rows that don't exist
-	 anymore.  This can happen when a window is split.  */
-      && mouse_face_end_row < w->current_matrix->nrows)
-    {
-      /* write_glyphs writes at cursor position, so we need to
-	 temporarily move cursor coordinates to the beginning of
-	 the highlight region.  */
-
-      /* Save current cursor co-ordinates */
-      save_y = curY (tty);
-      save_x = curX (tty);
-
-      /* Note that mouse_face_beg_row etc. are window relative.  */
-      for (i = mouse_face_beg_row; i <= mouse_face_end_row; i++)
-	{
-	  int start_hpos, end_hpos, nglyphs;
-	  struct glyph_row *row = MATRIX_ROW (w->current_matrix, i);
-
-	  /* Don't do anything if row doesn't have valid contents.  */
-	  if (!row->enabled_p)
-	    continue;
-
-	  /* For all but the first row, the highlight starts at column 0.  */
-	  if (i == mouse_face_beg_row)
-	    start_hpos = mouse_face_beg_col;
-	  else
-	    start_hpos = 0;
-
-	  if (i == mouse_face_end_row)
-	    end_hpos = mouse_face_end_col;
-	  else
-	    {
-	      end_hpos = row->used[TEXT_AREA];
-	      if (draw == DRAW_NORMAL_TEXT)
-		row->fill_line_p = 1; /* Clear to end of line */
-	    }
-
-	  if (end_hpos <= start_hpos)
-	    continue;
-	  /* Record that some glyphs of this row are displayed in
-	     mouse-face.  */
-	  row->mouse_face_p = draw > 0;
-
-	  nglyphs = end_hpos - start_hpos;
-
-	  if (end_hpos >= row->used[TEXT_AREA])
-	    nglyphs = row->used[TEXT_AREA] - start_hpos;
-
-	  pos_y = row->y + WINDOW_TOP_EDGE_Y (w);
-	  pos_x = row->used[LEFT_MARGIN_AREA] + start_hpos
-	    + WINDOW_LEFT_EDGE_X (w);
-
-	  cursor_to (f, pos_y, pos_x);
-
-	  if (draw == DRAW_MOUSE_FACE)
-	    {
-	      tty_write_glyphs_with_face (f, row->glyphs[TEXT_AREA] + start_hpos,
-				      nglyphs, mouse_face_face_id);
-	    }
-	  else /* draw == DRAW_NORMAL_TEXT */
-	    write_glyphs (f, row->glyphs[TEXT_AREA] + start_hpos, nglyphs);
-	}
-      cursor_to (f, save_y, save_x);
-    }
-}
-
-static void
-term_clear_mouse_face (void)
-{
-  if (!NILP (mouse_face_window))
-    term_show_mouse_face (DRAW_NORMAL_TEXT);
-
-  mouse_face_beg_row = mouse_face_beg_col = -1;
-  mouse_face_end_row = mouse_face_end_col = -1;
-  mouse_face_window = Qnil;
-}
-
-/* Find the glyph matrix position of buffer position POS in window W.
-   *HPOS and *VPOS are set to the positions found.  W's current glyphs
-   must be up to date.  If POS is above window start return (0, 0).
-   If POS is after end of W, return end of last line in W.
-   - taken from msdos.c */
-static int
-fast_find_position (struct window *w, EMACS_INT pos, int *hpos, int *vpos)
-{
-  int i, lastcol, maybe_next_line_p = 0;
-  EMACS_INT line_start_position;
-  int yb = window_text_bottom_y (w);
-  struct glyph_row *row = MATRIX_ROW (w->current_matrix, 0), *best_row = row;
-
-  while (row->y < yb)
-    {
-      if (row->used[TEXT_AREA])
-	line_start_position = row->glyphs[TEXT_AREA]->charpos;
-      else
-	line_start_position = 0;
-
-      if (line_start_position > pos)
-	break;
-      /* If the position sought is the end of the buffer,
-	 don't include the blank lines at the bottom of the window.  */
-      else if (line_start_position == pos
-	       && pos == BUF_ZV (XBUFFER (w->buffer)))
-	{
-	  maybe_next_line_p = 1;
-	  break;
-	}
-      else if (line_start_position > 0)
-	best_row = row;
-
-      /* Don't overstep the last matrix row, lest we get into the
-	 never-never land... */
-      if (row->y + 1 >= yb)
-	break;
-
-      ++row;
-    }
-
-  /* Find the right column within BEST_ROW.  */
-  lastcol = 0;
-  row = best_row;
-  for (i = 0; i < row->used[TEXT_AREA]; i++)
-    {
-      struct glyph *glyph = row->glyphs[TEXT_AREA] + i;
-      EMACS_INT charpos;
-
-      charpos = glyph->charpos;
-      if (charpos == pos)
-	{
-	  *hpos = i;
-	  *vpos = row->y;
-	  return 1;
-	}
-      else if (charpos > pos)
-	break;
-      else if (charpos > 0)
-	lastcol = i;
-    }
-
-  /* If we're looking for the end of the buffer,
-     and we didn't find it in the line we scanned,
-     use the start of the following line.  */
-  if (maybe_next_line_p)
-    {
-      ++row;
-      lastcol = 0;
-    }
-
-  *vpos = row->y;
-  *hpos = lastcol + 1;
-  return 0;
-}
-
-static void
-term_mouse_highlight (struct frame *f, int x, int y)
+/* Implementation of draw_row_with_mouse_face for TTY/GPM.  */
+void
+tty_draw_row_with_mouse_face (struct window *w, struct glyph_row *row,
+			      int start_hpos, int end_hpos,
+			      enum draw_glyphs_face draw)
 {
-  enum window_part part;
-  Lisp_Object window;
-  struct window *w;
-  struct buffer *b;
-
-  if (NILP (Vmouse_highlight)
-      || !f->glyphs_initialized_p)
-    return;
-
-  /* Which window is that in?  */
-  window = window_from_coordinates (f, x, y, &part, &x, &y, 0);
-
-  /* Not on a window -> return.  */
-  if (!WINDOWP (window))
-    return;
-
-  if (!EQ (window, mouse_face_window))
-    term_clear_mouse_face ();
-
-  w = XWINDOW (window);
-
-  /* Are we in a window whose display is up to date?
-     And verify the buffer's text has not changed.  */
-  b = XBUFFER (w->buffer);
-  if (part == ON_TEXT
-      && EQ (w->window_end_valid, w->buffer)
-      && XFASTINT (w->last_modified) == BUF_MODIFF (b)
-      && XFASTINT (w->last_overlay_modified) == BUF_OVERLAY_MODIFF (b))
-    {
-      int i, nrows = w->current_matrix->nrows;
-      EMACS_INT pos;
-      struct glyph_row *row;
-      struct glyph *glyph;
-
-      /* Find the glyph under X/Y.  */
-      glyph = NULL;
-      if (y >= 0 && y < nrows)
-	{
-	  row = MATRIX_ROW (w->current_matrix, y);
-	  /* Give up if some row before the one we are looking for is
-	     not enabled.  */
-	  for (i = 0; i <= y; i++)
-	    if (!MATRIX_ROW (w->current_matrix, i)->enabled_p)
-	      break;
-	  if (i > y  /* all rows upto and including the one at Y are enabled */
-	      && row->displays_text_p
-	      && x <  window_box_width (w, TEXT_AREA))
-	    {
-	      glyph = row->glyphs[TEXT_AREA];
-	      if (x >= row->used[TEXT_AREA])
-		glyph = NULL;
-	      else
-		{
-		  glyph += x;
-		  if (!BUFFERP (glyph->object))
-		    glyph = NULL;
-		}
-	    }
-	}
-
-      /* Clear mouse face if X/Y not over text.  */
-      if (glyph == NULL)
-	{
-	  term_clear_mouse_face ();
-	  return;
-	}
-
-      if (!BUFFERP (glyph->object))
-	abort ();
-      pos = glyph->charpos;
-
-      /* Check for mouse-face.  */
-      {
-	Lisp_Object mouse_face, overlay, position, *overlay_vec;
-	int noverlays;
-	EMACS_INT obegv, ozv;
-	struct buffer *obuf;
-
-	/* If we get an out-of-range value, return now; avoid an error.  */
-	if (pos > BUF_Z (b))
-	  return;
-
-	/* Make the window's buffer temporarily current for
-	   overlays_at and compute_char_face.  */
-	obuf = current_buffer;
-	current_buffer = b;
-	obegv = BEGV;
-	ozv = ZV;
-	BEGV = BEG;
-	ZV = Z;
-
-	/* Is this char mouse-active?  */
-	XSETINT (position, pos);
-
-	/* Put all the overlays we want in a vector in overlay_vec.  */
-	GET_OVERLAYS_AT (pos, overlay_vec, noverlays, NULL, 0);
-	/* Sort overlays into increasing priority order.  */
-	noverlays = sort_overlays (overlay_vec, noverlays, w);
-
-	/* Check mouse-face highlighting.  */
-	if (!(EQ (window, mouse_face_window)
-	      && y >= mouse_face_beg_row
-	      && y <= mouse_face_end_row
-	      && (y > mouse_face_beg_row
-		  || x >= mouse_face_beg_col)
-	      && (y < mouse_face_end_row
-		  || x < mouse_face_end_col
-		  || mouse_face_past_end)))
-	  {
-	    /* Clear the display of the old active region, if any.  */
-	    term_clear_mouse_face ();
-
-	    /* Find the highest priority overlay that has a mouse-face
-	       property.  */
-	    overlay = Qnil;
-	    for (i = noverlays - 1; i >= 0; --i)
-	      {
-		mouse_face = Foverlay_get (overlay_vec[i], Qmouse_face);
-		if (!NILP (mouse_face))
-		  {
-		    overlay = overlay_vec[i];
-		    break;
-		  }
-	      }
-
-	    /* If no overlay applies, get a text property.  */
-	    if (NILP (overlay))
-	      mouse_face = Fget_text_property (position, Qmouse_face,
-					       w->buffer);
-
-	    /* Handle the overlay case.  */
-	    if (!NILP (overlay))
-	      {
-		/* Find the range of text around this char that
-		   should be active.  */
-		Lisp_Object before, after;
-		EMACS_INT ignore;
-
-
-		before = Foverlay_start (overlay);
-		after = Foverlay_end (overlay);
-		/* Record this as the current active region.  */
-		fast_find_position (w, XFASTINT (before),
-				    &mouse_face_beg_col,
-				    &mouse_face_beg_row);
-
-		mouse_face_past_end
-		  = !fast_find_position (w, XFASTINT (after),
-					 &mouse_face_end_col,
-					 &mouse_face_end_row);
-		mouse_face_window = window;
-
-		mouse_face_face_id
-		  = face_at_buffer_position (w, pos, 0, 0,
-					     &ignore, pos + 1, 1, -1);
-
-		/* Display it as active.  */
-		term_show_mouse_face (DRAW_MOUSE_FACE);
-	      }
-	    /* Handle the text property case.  */
-	    else if (!NILP (mouse_face))
-	      {
-		/* Find the range of text around this char that
-		   should be active.  */
-		Lisp_Object before, after, beginning, end;
-		EMACS_INT ignore;
-
-		beginning = Fmarker_position (w->start);
-		XSETINT (end, (BUF_Z (b) - XFASTINT (w->window_end_pos)));
-		before
-		  = Fprevious_single_property_change (make_number (pos + 1),
-						      Qmouse_face,
-						      w->buffer, beginning);
-		after
-		  = Fnext_single_property_change (position, Qmouse_face,
-						  w->buffer, end);
-
-		/* Record this as the current active region.  */
-		fast_find_position (w, XFASTINT (before),
-				    &mouse_face_beg_col,
-				    &mouse_face_beg_row);
-		mouse_face_past_end
-		  = !fast_find_position (w, XFASTINT (after),
-					 &mouse_face_end_col,
-					 &mouse_face_end_row);
-		mouse_face_window = window;
-
-		mouse_face_face_id
-		  = face_at_buffer_position (w, pos, 0, 0,
-					     &ignore, pos + 1, 1, -1);
-
-		/* Display it as active.  */
-		term_show_mouse_face (DRAW_MOUSE_FACE);
-	      }
-	  }
-
-	/* Look for a `help-echo' property.  */
-	{
-	  Lisp_Object help;
-
-	  /* Check overlays first.  */
-	  help = Qnil;
-	  for (i = noverlays - 1; i >= 0 && NILP (help); --i)
-	    {
-	      overlay = overlay_vec[i];
-	      help = Foverlay_get (overlay, Qhelp_echo);
-	    }
-
-	  if (!NILP (help))
-	    {
-	      help_echo_string = help;
-	      help_echo_window = window;
-	      help_echo_object = overlay;
-	      help_echo_pos = pos;
-	    }
-	  /* Try text properties.  */
-	  else if (NILP (help)
-		   && ((STRINGP (glyph->object)
-			&& glyph->charpos >= 0
-			&& glyph->charpos < SCHARS (glyph->object))
-		       || (BUFFERP (glyph->object)
-			   && glyph->charpos >= BEGV
-			   && glyph->charpos < ZV)))
-	    {
-	      help = Fget_text_property (make_number (glyph->charpos),
-					 Qhelp_echo, glyph->object);
-	      if (!NILP (help))
-		{
-		  help_echo_string = help;
-		  help_echo_window = window;
-		  help_echo_object = glyph->object;
-		  help_echo_pos = glyph->charpos;
-		}
-	    }
-	}
-
-	BEGV = obegv;
-	ZV = ozv;
-	current_buffer = obuf;
-      }
-    }
+  int nglyphs = end_hpos - start_hpos;
+  struct frame *f = XFRAME (WINDOW_FRAME (w));
+  struct tty_display_info *tty = FRAME_TTY (f);
+  int face_id = tty->mouse_highlight.mouse_face_face_id;
+  int save_x, save_y, pos_x, pos_y;
+
+  if (end_hpos >= row->used[TEXT_AREA])
+    nglyphs = row->used[TEXT_AREA] - start_hpos;
+
+  pos_y = row->y + WINDOW_TOP_EDGE_Y (w);
+  pos_x = row->used[LEFT_MARGIN_AREA] + start_hpos + WINDOW_LEFT_EDGE_X (w);
+
+  /* Save current cursor co-ordinates.  */
+  save_y = curY (tty);
+  save_x = curX (tty);
+  cursor_to (f, pos_y, pos_x);
+
+  if (draw == DRAW_MOUSE_FACE)
+    tty_write_glyphs_with_face (f, row->glyphs[TEXT_AREA] + start_hpos,
+				nglyphs, face_id);
+  else if (draw == DRAW_NORMAL_TEXT)
+    write_glyphs (f, row->glyphs[TEXT_AREA] + start_hpos, nglyphs);
+
+  cursor_to (f, save_y, save_x);
 }
 
 static int
@@ -2936,7 +2711,7 @@
   if (event->x != last_mouse_x || event->y != last_mouse_y)
     {
       frame->mouse_moved = 1;
-      term_mouse_highlight (frame, event->x, event->y);
+      note_mouse_highlight (frame, event->x, event->y);
       /* Remember which glyph we're now on.  */
       last_mouse_x = event->x;
       last_mouse_y = event->y;
@@ -3407,7 +3182,7 @@
 
 #ifdef HAVE_GPM
   terminal->mouse_position_hook = term_mouse_position;
-  mouse_face_window = Qnil;
+  tty->mouse_highlight.mouse_face_window = Qnil;
 #endif
 
   
@@ -4042,8 +3817,6 @@
 #ifdef HAVE_GPM
   defsubr (&Sgpm_mouse_start);
   defsubr (&Sgpm_mouse_stop);
-
-  staticpro (&mouse_face_window);
 #endif /* HAVE_GPM */
 
 #ifndef DOS_NT
--- a/src/termchar.h	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/termchar.h	Mon Nov 08 14:19:54 2010 +0900
@@ -34,18 +34,18 @@
 struct tty_display_info
 {
   struct tty_display_info *next; /* Chain of all tty devices. */
-  
+
   char *name;                   /* The name of the device file or 0 if
                                    stdin/stdout. */
   char *type;                   /* The type of the tty. */
-  
+
   /* Input/output */
-  
+
   FILE *input;                  /* The stream to be used for terminal input.
                                    NULL if the terminal is suspended. */
   FILE *output;                 /* The stream to be used for terminal output.
                                    NULL if the terminal is suspended. */
-  
+
   FILE *termscript;             /* If nonzero, send all terminal output
                                    characters to this stream also.  */
 
@@ -65,38 +65,14 @@
   /* Redisplay. */
 
   Lisp_Object top_frame;        /* The topmost frame on this tty. */
-  
+
   /* The previous frame we displayed on this tty.  */
   struct frame *previous_frame;
   int previous_color_mode;
 
-#ifdef MSDOS
-  /* These variables describe the range of text currently shown in its
-     mouse-face, together with the window they apply to.  As long as
-     the mouse stays within this range, we need not redraw anything on
-     its account.  Rows and columns are glyph matrix positions in
-     MOUSE_FACE_WINDOW.  */
-  int mouse_face_beg_row, mouse_face_beg_col;
-  int mouse_face_end_row, mouse_face_end_col;
-  int mouse_face_past_end;
-  Lisp_Object mouse_face_window;
-  int mouse_face_face_id;
-
-  /* 1 if a mouse motion event came and we didn't handle it right away because
-     gc was in progress.  */
-  int mouse_face_deferred_gc;
-
-  /* FRAME and X, Y position of mouse when last checked for
-     highlighting.  X and Y can be negative or out of range for the frame.  */
-  struct frame *mouse_face_mouse_frame;
-  int mouse_face_mouse_x, mouse_face_mouse_y;
-
-  /* Nonzero means defer mouse-motion highlighting.  */
-  int mouse_face_defer;
-
-  /* Nonzero means that the mouse highlight should not be shown.  */
-  int mouse_face_hidden;
-#endif	/* !MSDOS */
+  /* Information about the range of text currently shown in
+     mouse-face.  */
+  Mouse_HLInfo mouse_highlight;
 
   /* Buffer used internally by termcap (see tgetent in the Termcap
      manual).  Only init_tty and delete_tty should change this.  */
@@ -190,12 +166,12 @@
   int RPov;                     /* # chars to start a TS_repeat */
 
   int delete_in_insert_mode;    /* delete mode == insert mode */
-  
+
   int se_is_so;                 /* 1 if same string both enters and leaves
                                    standout mode */
-  
+
   int costs_set;                /* Nonzero if costs have been calculated. */
-  
+
   int insert_mode;              /* Nonzero when in insert mode.  */
   int standout_mode;            /* Nonzero when in standout mode.  */
 
@@ -214,7 +190,7 @@
    lines from those operations.  */
 
   int specified_window;
-  
+
   /* Flag used in tty_show/hide_cursor.  */
 
   int cursor_hidden;
--- a/src/termhooks.h	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/termhooks.h	Mon Nov 08 14:19:54 2010 +0900
@@ -328,6 +328,11 @@
   /* Parameter alist of this terminal.  */
   Lisp_Object param_alist;
 
+  /* List of charsets supported by the terminal.  It is set by
+     Fset_terminal_coding_system_internal along with
+     the member terminal_coding.  */
+  Lisp_Object charset_list;
+
   /* All fields before `next_terminal' should be Lisp_Object and are traced
      by the GC.  All fields afterwards are ignored by the GC.  */
 
--- a/src/unexcoff.c	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/unexcoff.c	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/w16select.c	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/w32.c	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/w32fns.c	Mon Nov 08 14:19:54 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,
@@ -4513,7 +4511,8 @@
 
 
 DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
-       doc: /* Internal function called by `color-defined-p', which see.  */)
+       doc: /* Internal function called by `color-defined-p', which see.
+\(Note that the Nextstep version of this function ignores FRAME.)  */)
   (Lisp_Object color, Lisp_Object frame)
 {
   XColor foo;
@@ -4853,11 +4852,12 @@
 }
 
 DEFUN ("x-open-connection", Fx_open_connection, Sx_open_connection,
-       1, 3, 0, doc: /* Open a connection to a server.
+       1, 3, 0, doc: /* Open a connection to a display server.
 DISPLAY is the name of the display to connect to.
 Optional second arg XRM-STRING is a string of resources in xrdb format.
 If the optional third arg MUST-SUCCEED is non-nil,
-terminate Emacs if we can't open the connection.  */)
+terminate Emacs if we can't open the connection.
+\(In the Nextstep version, the last two arguments are currently ignored.)  */)
   (Lisp_Object display, Lisp_Object xrm_string, Lisp_Object must_succeed)
 {
   unsigned char *xrm_option;
@@ -4977,7 +4977,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 +5002,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 +5015,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 +5069,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 */
@@ -5637,7 +5657,7 @@
   int root_x, root_y;
   struct buffer *old_buffer;
   struct text_pos pos;
-  int i, width, height;
+  int i, width, height, seen_reversed_p;
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
   int old_windows_or_buffers_changed = windows_or_buffers_changed;
   int count = SPECPDL_INDEX ();
@@ -5767,7 +5787,7 @@
   try_window (FRAME_ROOT_WINDOW (f), pos, 0);
 
   /* Compute width and height of the tooltip.  */
-  width = height = 0;
+  width = height = seen_reversed_p = 0;
   for (i = 0; i < w->desired_matrix->nrows; ++i)
     {
       struct glyph_row *row = &w->desired_matrix->rows[i];
@@ -5781,24 +5801,83 @@
       /* Let the row go over the full width of the frame.  */
       row->full_width_p = 1;
 
-#ifdef TODO /* Investigate why some fonts need more width than is
-	       calculated for some tooltips.  */
-      /* There's a glyph at the end of rows that is use to place
-	 the cursor there.  Don't include the width of this glyph.  */
+      row_width = row->pixel_width;
       if (row->used[TEXT_AREA])
 	{
-	  last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1];
-	  row_width = row->pixel_width - last->pixel_width;
+	  if (!row->reversed_p)
+	    {
+#ifdef TODO   /* Investigate why some fonts need more width than is
+		 calculated for some tooltips.  */
+
+	      /* There's a glyph at the end of rows that is used to
+		 place the cursor there.  Don't include the width of
+		 this glyph.  */
+	      last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1];
+	      if (INTEGERP (last->object))
+		row_width -= last->pixel_width;
+#endif
+	    }
+	  else
+	    {
+	      /* There could be a stretch glyph at the beginning of R2L
+		 rows that is produced by extend_face_to_end_of_line.
+		 Don't count that glyph.  */
+	      struct glyph *g = row->glyphs[TEXT_AREA];
+
+	      if (g->type == STRETCH_GLYPH && INTEGERP (g->object))
+		{
+		  row_width -= g->pixel_width;
+		  seen_reversed_p = 1;
+		}
+	    }
 	}
-      else
-#endif
-	row_width = row->pixel_width;
 
       /* TODO: find why tips do not draw along baseline as instructed.  */
       height += row->height;
       width = max (width, row_width);
     }
 
+  /* If we've seen partial-length R2L rows, we need to re-adjust the
+     tool-tip frame width and redisplay it again, to avoid over-wide
+     tips due to the stretch glyph that extends R2L lines to full
+     width of the frame.  */
+  if (seen_reversed_p)
+    {
+      /* w->total_cols and FRAME_TOTAL_COLS want the width in columns,
+	 not in pixels.  */
+      width /= WINDOW_FRAME_COLUMN_WIDTH (w);
+      w->total_cols = make_number (width);
+      FRAME_TOTAL_COLS (f) = width;
+      adjust_glyphs (f);
+      clear_glyph_matrix (w->desired_matrix);
+      clear_glyph_matrix (w->current_matrix);
+      try_window (FRAME_ROOT_WINDOW (f), pos, 0);
+      width = height = 0;
+      /* Recompute width and height of the tooltip.  */
+      for (i = 0; i < w->desired_matrix->nrows; ++i)
+	{
+	  struct glyph_row *row = &w->desired_matrix->rows[i];
+	  struct glyph *last;
+	  int row_width;
+
+	  if (!row->enabled_p || !row->displays_text_p)
+	    break;
+	  row->full_width_p = 1;
+	  row_width = row->pixel_width;
+#ifdef TODO /* See above.  */
+	  if (row->used[TEXT_AREA] && !row->reversed_p)
+	    {
+	      last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1];
+	      if (INTEGERP (last->object))
+		row_width -= last->pixel_width;
+	    }
+#endif
+
+	  height += row->height;
+	  width = max (width, row_width);
+	}
+    }
+
   /* Add the frame's internal border to the width and height the X
      window should have.  */
   height += 2 * FRAME_INTERNAL_BORDER_WIDTH (f);
@@ -5903,7 +5982,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 +6030,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 ();
@@ -7246,5 +7328,3 @@
   return GetLastError ();
 }
 
-/* arch-tag: 707589ab-b9be-4638-8cdd-74629cc9b446
-   (do not change this comment) */
--- a/src/w32font.c	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/w32font.c	Mon Nov 08 14:19:54 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/w32gui.h	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/w32gui.h	Mon Nov 08 14:19:54 2010 +0900
@@ -59,13 +59,13 @@
 
 /* Dealing with bits of wchar_t as if they were an XChar2b.  */
 #define STORE_XCHAR2B(chp, byte1, byte2) \
-  ((*chp) = ((XChar2b)((((byte1) & 0x00ff) << 8) | ((byte2) & 0x00ff))))
+  ((*(chp)) = ((XChar2b)((((byte1) & 0x00ff) << 8) | ((byte2) & 0x00ff))))
 
 #define XCHAR2B_BYTE1(chp) \
- (((*chp) & 0xff00) >> 8)
+  (((*(chp)) & 0xff00) >> 8)
 
 #define XCHAR2B_BYTE2(chp) \
- ((*chp) & 0x00ff)
+  ((*(chp)) & 0x00ff)
 
 
 /* Windows equivalent of XImage.  */
--- a/src/w32heap.c	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/w32heap.c	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/w32inevt.c	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/w32menu.c	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/w32proc.c	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/w32select.c	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/w32term.c	Mon Nov 08 14:19:54 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.
 
@@ -504,7 +505,7 @@
 x_update_window_begin (struct window *w)
 {
   struct frame *f = XFRAME (WINDOW_FRAME (w));
-  struct w32_display_info *display_info = FRAME_W32_DISPLAY_INFO (f);
+  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
 
   /* Hide the system caret during an update.  */
   if (w32_use_visible_system_caret && w32_system_caret_hwnd)
@@ -517,15 +518,15 @@
 
   BLOCK_INPUT;
 
-  if (f == display_info->mouse_face_mouse_frame)
+  if (f == hlinfo->mouse_face_mouse_frame)
     {
       /* Don't do highlighting for mouse motion during the update.  */
-      display_info->mouse_face_defer = 1;
+      hlinfo->mouse_face_defer = 1;
 
       /* If F needs to be redrawn, simply forget about any prior mouse
 	 highlighting.  */
       if (FRAME_GARBAGED_P (f))
-	display_info->mouse_face_window = Qnil;
+	hlinfo->mouse_face_window = Qnil;
 
 #if 0 /* Rows in a current matrix containing glyphs in mouse-face have
 	 their mouse_face_p flag set, which means that they are always
@@ -539,8 +540,8 @@
 	 Likewise, don't do anything if the frame is garbaged;
 	 in that case, the frame's current matrix that we would use
 	 is all wrong, and we will redisplay that line anyway.  */
-      if (!NILP (display_info->mouse_face_window)
-	  && w == XWINDOW (display_info->mouse_face_window))
+      if (!NILP (hlinfo->mouse_face_window)
+	  && w == XWINDOW (hlinfo->mouse_face_window))
 	{
 	  int i;
 
@@ -549,7 +550,7 @@
 	      break;
 
 	  if (i < w->desired_matrix->nrows)
-	    clear_mouse_face (display_info);
+	    clear_mouse_face (hlinfo);
 	}
 #endif /* 0 */
     }
@@ -600,7 +601,7 @@
 x_update_window_end (struct window *w, int cursor_on_p,
 		     int mouse_face_overwritten_p)
 {
-  struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (XFRAME (w->frame));
+  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (XFRAME (w->frame));
 
   if (!w->pseudo_window_p)
     {
@@ -621,9 +622,9 @@
      XTframe_up_to_date to redisplay the mouse highlight.  */
   if (mouse_face_overwritten_p)
     {
-      dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1;
-      dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
-      dpyinfo->mouse_face_window = Qnil;
+      hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
+      hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
+      hlinfo->mouse_face_window = Qnil;
     }
 
   /* Unhide the caret.  This won't actually show the cursor, unless it
@@ -648,7 +649,7 @@
     return;
 
   /* Mouse highlight may be displayed again.  */
-  FRAME_W32_DISPLAY_INFO (f)->mouse_face_defer = 0;
+  MOUSE_HL_INFO (f)->mouse_face_defer = 0;
 }
 
 
@@ -661,17 +662,17 @@
 {
   if (FRAME_W32_P (f))
     {
-      struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f);
-
-      if (dpyinfo->mouse_face_deferred_gc
-	  || f == dpyinfo->mouse_face_mouse_frame)
+      Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
+
+      if (hlinfo->mouse_face_deferred_gc
+	  || f == hlinfo->mouse_face_mouse_frame)
 	{
 	  BLOCK_INPUT;
-	  if (dpyinfo->mouse_face_mouse_frame)
-	    note_mouse_highlight (dpyinfo->mouse_face_mouse_frame,
-				  dpyinfo->mouse_face_mouse_x,
-				  dpyinfo->mouse_face_mouse_y);
-	  dpyinfo->mouse_face_deferred_gc = 0;
+	  if (hlinfo->mouse_face_mouse_frame)
+	    note_mouse_highlight (hlinfo->mouse_face_mouse_frame,
+				  hlinfo->mouse_face_mouse_x,
+				  hlinfo->mouse_face_mouse_y);
+	  hlinfo->mouse_face_deferred_gc = 0;
 	  UNBLOCK_INPUT;
 	}
     }
@@ -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
@@ -998,7 +999,7 @@
   struct face *face;
 
   /* What face has to be used last for the mouse face?  */
-  face_id = FRAME_W32_DISPLAY_INFO (s->f)->mouse_face_face_id;
+  face_id = MOUSE_HL_INFO (s->f)->mouse_face_face_id;
   face = FACE_FROM_ID (s->f, face_id);
   if (face == NULL)
     face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
@@ -1393,6 +1394,94 @@
 }
 
 
+/* Draw the foreground of glyph string S for glyphless characters.  */
+
+static void
+x_draw_glyphless_glyph_string_foreground (struct glyph_string *s)
+{
+  struct glyph *glyph = s->first_glyph;
+  XChar2b char2b[8];
+  int x, i, j;
+  int with_background;
+
+  /* If first glyph of S has a left box line, start drawing the text
+     of S to the right of that box line.  */
+  if (s->face->box != FACE_NO_BOX
+      && s->first_glyph->left_box_line_p)
+    x = s->x + eabs (s->face->box_line_width);
+  else
+    x = s->x;
+
+  SetTextColor (s->hdc, s->gc->foreground);
+  SetBkColor (s->hdc, s->gc->background);
+  SetTextAlign (s->hdc, TA_BASELINE | TA_LEFT);
+
+  s->char2b = char2b;
+  with_background = ! (s->for_overlaps
+		       || (s->background_filled_p && s->hl != DRAW_CURSOR));
+  for (i = 0; i < s->nchars; i++, glyph++)
+    {
+      char buf[7], *str = NULL;
+      int len = glyph->u.glyphless.len;
+
+      if (glyph->u.glyphless.method == GLYPHLESS_DISPLAY_ACRONYM)
+	{
+	  if (len > 1
+	      && CHAR_TABLE_P (Vglyphless_char_display)
+	      && (CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (Vglyphless_char_display))
+		  >= 1))
+	    {
+	      Lisp_Object acronym
+		= (! glyph->u.glyphless.for_no_font
+		   ? CHAR_TABLE_REF (Vglyphless_char_display,
+				     glyph->u.glyphless.ch)
+		   : XCHAR_TABLE (Vglyphless_char_display)->extras[0]);
+	      if (STRINGP (acronym))
+		str = (char *) SDATA (acronym);
+	    }
+	}
+      else if (glyph->u.glyphless.method == GLYPHLESS_DISPLAY_HEXA_CODE)
+	{
+	  sprintf ((char *) buf, "%0*X",
+		   glyph->u.glyphless.ch < 0x10000 ? 4 : 6,
+		   glyph->u.glyphless.ch);
+	  str = buf;
+	}
+
+      if (str)
+	{
+	  struct font *font = s->font;
+	  int upper_len = (len + 1) / 2;
+	  unsigned code;
+	  HFONT old_font;
+
+	  old_font = SelectObject (s->hdc, FONT_HANDLE (font));
+	  /* It is assured that all LEN characters in STR is ASCII.  */
+	  for (j = 0; j < len; j++)
+	    {
+	      code = font->driver->encode_char (font, str[j]);
+	      STORE_XCHAR2B (char2b + j, code >> 8, code & 0xFF);
+	    }
+	  font->driver->draw (s, 0, upper_len,
+			      x + glyph->slice.glyphless.upper_xoff,
+			      s->ybase + glyph->slice.glyphless.upper_yoff,
+			      with_background);
+	  font->driver->draw (s, upper_len, len,
+			      x + glyph->slice.glyphless.lower_xoff,
+			      s->ybase + glyph->slice.glyphless.lower_yoff,
+			      with_background);
+	  SelectObject (s->hdc, old_font);
+	}
+      if (glyph->u.glyphless.method != GLYPHLESS_DISPLAY_THIN_SPACE)
+	w32_draw_rectangle (s->hdc, s->gc,
+			    x, s->ybase - glyph->ascent,
+			    glyph->pixel_width - 1,
+			    glyph->ascent + glyph->descent - 1);
+      x += glyph->pixel_width;
+   }
+}
+
+
 /* Brightness beyond which a color won't have its highlight brightness
    boosted.
 
@@ -2281,6 +2370,14 @@
       x_draw_composite_glyph_string_foreground (s);
       break;
 
+    case GLYPHLESS_GLYPH:
+      if (s->for_overlaps)
+	s->background_filled_p = 1;
+      else
+	x_draw_glyph_string_background (s, 0);
+      x_draw_glyphless_glyph_string_foreground (s);
+      break;
+
     default:
       abort ();
     }
@@ -3954,7 +4051,7 @@
    recursively with different messages by the system.
 */
 
-int
+static int
 w32_read_socket (struct terminal *terminal, int expected,
 		 struct input_event *hold_quit)
 {
@@ -3963,6 +4060,7 @@
   W32Msg msg;
   struct frame *f;
   struct w32_display_info *dpyinfo = &one_w32_display_info;
+  Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight;
 
   if (interrupt_input_blocked)
     {
@@ -4063,11 +4161,11 @@
 
 	  if (f && !f->iconified)
 	    {
-	      if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)
-		  && !EQ (f->tool_bar_window, dpyinfo->mouse_face_window))
+	      if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)
+		  && !EQ (f->tool_bar_window, hlinfo->mouse_face_window))
 		{
-		  clear_mouse_face (dpyinfo);
-		  dpyinfo->mouse_face_hidden = 1;
+		  clear_mouse_face (hlinfo);
+		  hlinfo->mouse_face_hidden = 1;
 		}
 
 	      if (temp_index == sizeof temp_buffer / sizeof (short))
@@ -4088,11 +4186,11 @@
 
 	  if (f && !f->iconified)
 	    {
-	      if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)
-		  && !EQ (f->tool_bar_window, dpyinfo->mouse_face_window))
+	      if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)
+		  && !EQ (f->tool_bar_window, hlinfo->mouse_face_window))
 		{
-		  clear_mouse_face (dpyinfo);
-		  dpyinfo->mouse_face_hidden = 1;
+		  clear_mouse_face (hlinfo);
+		  hlinfo->mouse_face_hidden = 1;
 		}
 
 	      if (temp_index == sizeof temp_buffer / sizeof (short))
@@ -4166,11 +4264,11 @@
 
 	  if (f && !f->iconified)
 	    {
-	      if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)
-		  && !EQ (f->tool_bar_window, dpyinfo->mouse_face_window))
+	      if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)
+		  && !EQ (f->tool_bar_window, hlinfo->mouse_face_window))
 		{
-		  clear_mouse_face (dpyinfo);
-		  dpyinfo->mouse_face_hidden = 1;
+		  clear_mouse_face (hlinfo);
+		  hlinfo->mouse_face_hidden = 1;
 		}
 
 	      if (temp_index == sizeof temp_buffer / sizeof (short))
@@ -4204,10 +4302,10 @@
 	  else
 	    f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
 
-	  if (dpyinfo->mouse_face_hidden)
+	  if (hlinfo->mouse_face_hidden)
 	    {
-	      dpyinfo->mouse_face_hidden = 0;
-	      clear_mouse_face (dpyinfo);
+	      hlinfo->mouse_face_hidden = 0;
+	      clear_mouse_face (hlinfo);
 	    }
 
 	  if (f)
@@ -4239,7 +4337,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;
@@ -4248,7 +4346,7 @@
             {
               /* If we move outside the frame, then we're
                  certainly no longer on any text in the frame.  */
-              clear_mouse_face (dpyinfo);
+              clear_mouse_face (hlinfo);
             }
 
           /* If the contents of the global variable help_echo_string
@@ -4537,12 +4635,12 @@
 	  f = x_any_window_to_frame (dpyinfo, msg.msg.hwnd);
 	  if (f)
 	    {
-	      if (f == dpyinfo->mouse_face_mouse_frame)
+	      if (f == hlinfo->mouse_face_mouse_frame)
 		{
 		  /* If we move outside the frame, then we're
 		     certainly no longer on any text in the frame.  */
-		  clear_mouse_face (dpyinfo);
-		  dpyinfo->mouse_face_mouse_frame = 0;
+		  clear_mouse_face (hlinfo);
+		  hlinfo->mouse_face_mouse_frame = 0;
 		}
 
 	      /* Generate a nil HELP_EVENT to cancel a help-echo.
@@ -4572,12 +4670,12 @@
               if (f == dpyinfo->w32_focus_frame)
                 x_new_focus_frame (dpyinfo, 0);
 
-              if (f == dpyinfo->mouse_face_mouse_frame)
+              if (f == hlinfo->mouse_face_mouse_frame)
                 {
                   /* If we move outside the frame, then we're
                      certainly no longer on any text in the frame.  */
-                  clear_mouse_face (dpyinfo);
-                  dpyinfo->mouse_face_mouse_frame = 0;
+                  clear_mouse_face (hlinfo);
+                  hlinfo->mouse_face_mouse_frame = 0;
                 }
 
               /* Generate a nil HELP_EVENT to cancel a help-echo.
@@ -5601,7 +5699,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
@@ -5725,6 +5823,7 @@
 x_free_frame_resources (struct frame *f)
 {
   struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f);
+  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
 
   BLOCK_INPUT;
 
@@ -5763,15 +5862,15 @@
   if (f == dpyinfo->x_highlight_frame)
     dpyinfo->x_highlight_frame = 0;
 
-  if (f == dpyinfo->mouse_face_mouse_frame)
+  if (f == hlinfo->mouse_face_mouse_frame)
     {
-      dpyinfo->mouse_face_beg_row
-	= dpyinfo->mouse_face_beg_col = -1;
-      dpyinfo->mouse_face_end_row
-	= dpyinfo->mouse_face_end_col = -1;
-      dpyinfo->mouse_face_window = Qnil;
-      dpyinfo->mouse_face_deferred_gc = 0;
-      dpyinfo->mouse_face_mouse_frame = 0;
+      hlinfo->mouse_face_beg_row
+	= hlinfo->mouse_face_beg_col = -1;
+      hlinfo->mouse_face_end_row
+	= hlinfo->mouse_face_end_col = -1;
+      hlinfo->mouse_face_window = Qnil;
+      hlinfo->mouse_face_deferred_gc = 0;
+      hlinfo->mouse_face_mouse_frame = 0;
     }
 
   UNBLOCK_INPUT;
@@ -5837,6 +5936,7 @@
 w32_initialize_display_info (Lisp_Object display_name)
 {
   struct w32_display_info *dpyinfo = &one_w32_display_info;
+  Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight;
 
   memset (dpyinfo, 0, sizeof (*dpyinfo));
 
@@ -5862,12 +5962,12 @@
   dpyinfo->smallest_font_height = 1;
   dpyinfo->smallest_char_width = 1;
 
-  dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1;
-  dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
-  dpyinfo->mouse_face_face_id = DEFAULT_FACE_ID;
-  dpyinfo->mouse_face_window = Qnil;
-  dpyinfo->mouse_face_overlay = Qnil;
-  dpyinfo->mouse_face_hidden = 0;
+  hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
+  hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
+  hlinfo->mouse_face_face_id = DEFAULT_FACE_ID;
+  hlinfo->mouse_face_window = Qnil;
+  hlinfo->mouse_face_overlay = Qnil;
+  hlinfo->mouse_face_hidden = 0;
 
   dpyinfo->vertical_scroll_bar_cursor = w32_load_cursor (IDC_ARROW);
   /* TODO: dpyinfo->gray */
@@ -6336,7 +6436,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 +6450,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/w32term.h	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/w32term.h	Mon Nov 08 14:19:54 2010 +0900
@@ -143,36 +143,9 @@
   /* Reusable Graphics Context for drawing a cursor in a non-default face. */
   XGCValues *scratch_cursor_gc;
 
-  /* These variables describe the range of text currently shown in its
-     mouse-face, together with the window they apply to. As long as
-     the mouse stays within this range, we need not redraw anything on
-     its account.  Rows and columns are glyph matrix positions in
-     MOUSE_FACE_WINDOW.  */
-  int mouse_face_beg_row, mouse_face_beg_col;
-  int mouse_face_beg_x, mouse_face_beg_y;
-  int mouse_face_end_row, mouse_face_end_col;
-  int mouse_face_end_x, mouse_face_end_y;
-  int mouse_face_past_end;
-  Lisp_Object mouse_face_window;
-  int mouse_face_face_id;
-  Lisp_Object mouse_face_overlay;
-
-  /* 1 if a mouse motion event came and we didn't handle it right away because
-     gc was in progress.  */
-  int mouse_face_deferred_gc;
-
-  /* FRAME and X, Y position of mouse when last checked for
-     highlighting.  X and Y can be negative or out of range for the frame.  */
-  struct frame *mouse_face_mouse_frame;
-  int mouse_face_mouse_x, mouse_face_mouse_y;
-
-  /* Nonzero means defer mouse-motion highlighting.  */
-  int mouse_face_defer;
-
-  /* Nonzero means that the mouse highlight should not be shown.  */
-  int mouse_face_hidden;
-
-  int mouse_face_image_state;
+  /* Information about the range of text currently shown in
+     mouse-face.  */
+  Mouse_HLInfo mouse_highlight;
 
   char *w32_id_name;
 
--- a/src/w32uniscribe.c	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/w32uniscribe.c	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/w32xfns.c	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/xdisp.c	Mon Nov 08 14:19:54 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.
 
@@ -214,11 +214,41 @@
    leftmost character with special glyphs, which will display as,
    well, empty.  On text terminals, these special glyphs are simply
    blank characters.  On graphics terminals, there's a single stretch
-   glyph with suitably computed width.  Both the blanks and the
+   glyph of a suitably computed width.  Both the blanks and the
    stretch glyph are given the face of the background of the line.
    This way, the terminal-specific back-end can still draw the glyphs
    left to right, even for R2L lines.
 
+   Bidirectional display and character compositions
+
+   Some scripts cannot be displayed by drawing each character
+   individually, because adjacent characters change each other's shape
+   on display.  For example, Arabic and Indic scripts belong to this
+   category.
+
+   Emacs display supports this by providing "character compositions",
+   most of which is implemented in composite.c.  During the buffer
+   scan that delivers characters to PRODUCE_GLYPHS, if the next
+   character to be delivered is a composed character, the iteration
+   calls composition_reseat_it and next_element_from_composition.  If
+   they succeed to compose the character with one or more of the
+   following characters, the whole sequence of characters that where
+   composed is recorded in the `struct composition_it' object that is
+   part of the buffer iterator.  The composed sequence could produce
+   one or more font glyphs (called "grapheme clusters") on the screen.
+   Each of these grapheme clusters is then delivered to PRODUCE_GLYPHS
+   in the direction corresponding to the current bidi scan direction
+   (recorded in the scan_dir member of the `struct bidi_it' object
+   that is part of the buffer iterator).  In particular, if the bidi
+   iterator currently scans the buffer backwards, the grapheme
+   clusters are delivered back to front.  This reorders the grapheme
+   clusters as appropriate for the current bidi context.  Note that
+   this means that the grapheme clusters are always stored in the
+   LGSTRING object (see composite.c) in the logical order.
+
+   Moving an iterator in bidirectional text
+   without producing glyphs
+
    Note one important detail mentioned above: that the bidi reordering
    engine, driven by the iterator, produces characters in R2L rows
    starting at the character that will be the rightmost on display.
@@ -888,6 +918,9 @@
 #ifdef HAVE_WINDOW_SYSTEM
 #define CLEAR_IMAGE_CACHE_COUNT	101
 static int clear_image_cache_count;
+
+/* Null glyph slice */
+static struct glyph_slice null_glyph_slice = { 0, 0, 0, 0 };
 #endif
 
 /* Non-zero while redisplay_internal is in progress.  */
@@ -913,10 +946,6 @@
 
 Lisp_Object previous_help_echo_string;
 
-/* Null glyph slice */
-
-static struct glyph_slice null_glyph_slice = { 0, 0, 0, 0 };
-
 /* Platform-independent portion of hourglass implementation. */
 
 /* Non-zero means we're allowed to display a hourglass pointer.  */
@@ -932,6 +961,21 @@
 /* Number of seconds to wait before displaying an hourglass cursor.  */
 Lisp_Object Vhourglass_delay;
 
+/* Name of the face used to display glyphless characters.  */
+Lisp_Object Qglyphless_char;
+
+/* Char-table to control the display of glyphless characters.  */
+Lisp_Object Vglyphless_char_display;
+
+/* Symbol for the purpose of Vglyphless_char_display.  */
+Lisp_Object Qglyphless_char_display;
+
+/* Method symbols for Vglyphless_char_display.  */
+static Lisp_Object Qhexa_code, Qempty_box, Qthin_space, Qzero_width;
+
+/* Default pixel width of `thin-space' display method.  */
+#define THIN_SPACE_WIDTH 1
+
 /* Default number of seconds to wait before displaying an hourglass
    cursor.  */
 #define DEFAULT_HOURGLASS_DELAY 1
@@ -960,10 +1004,8 @@
 					  EMACS_INT, EMACS_INT);
 static void store_mode_line_noprop_char (char);
 static int store_mode_line_noprop (const unsigned char *, int, int);
-static void x_consider_frame_title (Lisp_Object);
 static void handle_stop (struct it *);
 static void handle_stop_backwards (struct it *, EMACS_INT);
-static int tool_bar_lines_needed (struct frame *, int *);
 static int single_display_spec_intangible_p (Lisp_Object);
 static void ensure_echo_area_buffers (void);
 static Lisp_Object unwind_with_echo_area_buffer (Lisp_Object);
@@ -1076,6 +1118,8 @@
 
 #ifdef HAVE_WINDOW_SYSTEM
 
+static void x_consider_frame_title (Lisp_Object);
+static int tool_bar_lines_needed (struct frame *, int *);
 static void update_tool_bar (struct frame *, int);
 static void build_desired_tool_bar_string (struct frame *f);
 static int redisplay_tool_bar (struct frame *);
@@ -1087,9 +1131,11 @@
                                   int, int, int);
 
 
-
 #endif /* HAVE_WINDOW_SYSTEM */
 
+static int coords_in_mouse_face_p (struct window *, int, int);
+
+
 
 /***********************************************************************
 		      Window display dimensions
@@ -1781,8 +1827,6 @@
 }
 
 
-#ifdef HAVE_WINDOW_SYSTEM
-
 /* Find the glyph under window-relative coordinates X/Y in window W.
    Consider only glyphs from buffer text, i.e. no glyphs from overlay
    strings.  Return in *HPOS and *VPOS the row and column number of
@@ -1865,7 +1909,6 @@
   return glyph;
 }
 
-
 /* EXPORT:
    Convert frame-relative x/y to coordinates relative to window W.
    Takes pseudo-windows into account.  */
@@ -1888,6 +1931,8 @@
     }
 }
 
+#ifdef HAVE_WINDOW_SYSTEM
+
 /* EXPORT:
    Return in RECTS[] at most N clipping rectangles for glyph string S.
    Return the number of stored rectangles.  */
@@ -5731,6 +5776,57 @@
 				 (IT)->string)))
 
 
+/* Lookup the char-table Vglyphless_char_display for character C (-1
+   if we want information for no-font case), and return the display
+   method symbol.  By side-effect, update it->what and
+   it->glyphless_method.  This function is called from
+   get_next_display_element for each character element, and from
+   x_produce_glyphs when no suitable font was found.  */
+
+Lisp_Object
+lookup_glyphless_char_display (int c, struct it *it)
+{
+  Lisp_Object glyphless_method = Qnil;
+
+  if (CHAR_TABLE_P (Vglyphless_char_display)
+      && CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (Vglyphless_char_display)) >= 1)
+    glyphless_method = (c >= 0
+			? CHAR_TABLE_REF (Vglyphless_char_display, c)
+			: XCHAR_TABLE (Vglyphless_char_display)->extras[0]);
+ retry:
+  if (NILP (glyphless_method))
+    {
+      if (c >= 0)
+	/* The default is to display the character by a proper font.  */
+	return Qnil;
+      /* The default for the no-font case is to display an empty box.  */
+      glyphless_method = Qempty_box;
+    }
+  if (EQ (glyphless_method, Qzero_width))
+    {
+      if (c >= 0)
+	return glyphless_method;
+      /* This method can't be used for the no-font case.  */
+      glyphless_method = Qempty_box;
+    }
+  if (EQ (glyphless_method, Qthin_space))
+    it->glyphless_method = GLYPHLESS_DISPLAY_THIN_SPACE;
+  else if (EQ (glyphless_method, Qempty_box))
+    it->glyphless_method = GLYPHLESS_DISPLAY_EMPTY_BOX;
+  else if (EQ (glyphless_method, Qhexa_code))
+    it->glyphless_method = GLYPHLESS_DISPLAY_HEXA_CODE;
+  else if (STRINGP (glyphless_method))
+    it->glyphless_method = GLYPHLESS_DISPLAY_ACRONYM;
+  else
+    {
+      /* Invalid value.  We use the default method.  */
+      glyphless_method = Qnil;
+      goto retry;
+    }
+  it->what = IT_GLYPHLESS;
+  return glyphless_method;
+}
+
 /* Load IT's display element fields with information about the next
    display element from the current position of IT.  Value is zero if
    end of buffer (or C string) is reached.  */
@@ -5739,6 +5835,10 @@
 static unsigned last_escape_glyph_face_id = (1 << FACE_ID_BITS);
 static int last_escape_glyph_merged_face_id = 0;
 
+struct frame *last_glyphless_glyph_frame = NULL;
+unsigned last_glyphless_glyph_face_id = (1 << FACE_ID_BITS);
+int last_glyphless_glyph_merged_face_id = 0;
+
 int
 get_next_display_element (struct it *it)
 {
@@ -5817,6 +5917,15 @@
 	      goto get_next;
 	    }
 
+	  if (! NILP (lookup_glyphless_char_display (c, it)))
+	    {
+	      if (it->what == IT_GLYPHLESS)
+		goto done;
+	      /* Don't display this character.  */
+	      set_iterator_to_next (it, 0);
+	      goto get_next;
+	    }
+
 	  if (! ASCII_CHAR_P (c) && ! NILP (Vnobreak_char_display))
 	    nbsp_or_shy = (c == 0xA0   ? char_is_nbsp
 			   : c == 0xAD ? char_is_soft_hyphen
@@ -6031,6 +6140,7 @@
     }
 #endif
 
+ done:
   /* Is this character the last one of a run of characters with
      box?  If yes, set IT->end_of_box_run_p to 1.  */
   if (it->face_box_p
@@ -10737,7 +10847,7 @@
 get_tool_bar_item (struct frame *f, int x, int y, struct glyph **glyph,
 		   int *hpos, int *vpos, int *prop_idx)
 {
-  Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
+  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
   struct window *w = XWINDOW (f->tool_bar_window);
   int area;
 
@@ -10752,14 +10862,14 @@
     return -1;
 
   /* Is mouse on the highlighted item?  */
-  if (EQ (f->tool_bar_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))
+  if (EQ (f->tool_bar_window, hlinfo->mouse_face_window)
+      && *vpos >= hlinfo->mouse_face_beg_row
+      && *vpos <= hlinfo->mouse_face_end_row
+      && (*vpos > hlinfo->mouse_face_beg_row
+	  || *hpos >= hlinfo->mouse_face_beg_col)
+      && (*vpos < hlinfo->mouse_face_end_row
+	  || *hpos < hlinfo->mouse_face_end_col
+	  || hlinfo->mouse_face_past_end))
     return 0;
 
   return 1;
@@ -10776,7 +10886,7 @@
 handle_tool_bar_click (struct frame *f, int x, int y, int down_p,
 		       unsigned int modifiers)
 {
-  Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
+  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
   struct window *w = XWINDOW (f->tool_bar_window);
   int hpos, vpos, prop_idx;
   struct glyph *glyph;
@@ -10795,8 +10905,8 @@
   if (down_p)
     {
       /* Show item in pressed state.  */
-      show_mouse_face (dpyinfo, DRAW_IMAGE_SUNKEN);
-      dpyinfo->mouse_face_image_state = DRAW_IMAGE_SUNKEN;
+      show_mouse_face (hlinfo, DRAW_IMAGE_SUNKEN);
+      hlinfo->mouse_face_image_state = DRAW_IMAGE_SUNKEN;
       last_tool_bar_item = prop_idx;
     }
   else
@@ -10806,8 +10916,8 @@
       EVENT_INIT (event);
 
       /* Show item in released state.  */
-      show_mouse_face (dpyinfo, DRAW_IMAGE_RAISED);
-      dpyinfo->mouse_face_image_state = DRAW_IMAGE_RAISED;
+      show_mouse_face (hlinfo, DRAW_IMAGE_RAISED);
+      hlinfo->mouse_face_image_state = DRAW_IMAGE_RAISED;
 
       key = AREF (f->tool_bar_items, prop_idx + TOOL_BAR_ITEM_KEY);
 
@@ -10837,6 +10947,7 @@
   Lisp_Object window = f->tool_bar_window;
   struct window *w = XWINDOW (window);
   Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
+  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
   int hpos, vpos;
   struct glyph *glyph;
   struct glyph_row *row;
@@ -10850,7 +10961,7 @@
      values when mouse moves outside of the frame.  */
   if (x <= 0 || y <= 0)
     {
-      clear_mouse_face (dpyinfo);
+      clear_mouse_face (hlinfo);
       return;
     }
 
@@ -10858,14 +10969,14 @@
   if (rc < 0)
     {
       /* Not on tool-bar item.  */
-      clear_mouse_face (dpyinfo);
+      clear_mouse_face (hlinfo);
       return;
     }
   else if (rc == 0)
     /* On same tool-bar item as before.  */
     goto set_help_echo;
 
-  clear_mouse_face (dpyinfo);
+  clear_mouse_face (hlinfo);
 
   /* Mouse is down, but on different tool-bar item?  */
   mouse_down_p = (dpyinfo->grabbed
@@ -10875,7 +10986,7 @@
       && last_tool_bar_item != prop_idx)
     return;
 
-  dpyinfo->mouse_face_image_state = DRAW_NORMAL_TEXT;
+  hlinfo->mouse_face_image_state = DRAW_NORMAL_TEXT;
   draw = mouse_down_p ? DRAW_IMAGE_SUNKEN : DRAW_IMAGE_RAISED;
 
   /* If tool-bar item is not enabled, don't highlight it.  */
@@ -10889,22 +11000,22 @@
 	x += row->glyphs[TEXT_AREA][i].pixel_width;
 
       /* Record this as the current active region.  */
-      dpyinfo->mouse_face_beg_col = hpos;
-      dpyinfo->mouse_face_beg_row = vpos;
-      dpyinfo->mouse_face_beg_x = x;
-      dpyinfo->mouse_face_beg_y = row->y;
-      dpyinfo->mouse_face_past_end = 0;
-
-      dpyinfo->mouse_face_end_col = hpos + 1;
-      dpyinfo->mouse_face_end_row = vpos;
-      dpyinfo->mouse_face_end_x = x + glyph->pixel_width;
-      dpyinfo->mouse_face_end_y = row->y;
-      dpyinfo->mouse_face_window = window;
-      dpyinfo->mouse_face_face_id = TOOL_BAR_FACE_ID;
+      hlinfo->mouse_face_beg_col = hpos;
+      hlinfo->mouse_face_beg_row = vpos;
+      hlinfo->mouse_face_beg_x = x;
+      hlinfo->mouse_face_beg_y = row->y;
+      hlinfo->mouse_face_past_end = 0;
+
+      hlinfo->mouse_face_end_col = hpos + 1;
+      hlinfo->mouse_face_end_row = vpos;
+      hlinfo->mouse_face_end_x = x + glyph->pixel_width;
+      hlinfo->mouse_face_end_y = row->y;
+      hlinfo->mouse_face_window = window;
+      hlinfo->mouse_face_face_id = TOOL_BAR_FACE_ID;
 
       /* Display it as active.  */
-      show_mouse_face (dpyinfo, draw);
-      dpyinfo->mouse_face_image_state = draw;
+      show_mouse_face (hlinfo, draw);
+      hlinfo->mouse_face_image_state = draw;
     }
 
  set_help_echo:
@@ -11578,6 +11689,8 @@
   reconsider_clip_changes (w, current_buffer);
   last_escape_glyph_frame = NULL;
   last_escape_glyph_face_id = (1 << FACE_ID_BITS);
+  last_glyphless_glyph_frame = NULL;
+  last_glyphless_glyph_face_id = (1 << FACE_ID_BITS);
 
   /* If new fonts have been loaded that make a glyph matrix adjustment
      necessary, do it.  */
@@ -15333,10 +15446,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 +15463,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;
     }
@@ -15897,6 +16015,9 @@
 		     + (WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0)
 		     + window_internal_height (w));
 
+#if defined (HAVE_GPM) || defined (MSDOS)
+	  x_clear_window_mouse_face (w);
+#endif
 	  /* Perform the operation on the screen.  */
 	  if (dvpos > 0)
 	    {
@@ -20651,6 +20772,42 @@
 }
 
 
+/* Fill glyph string S from a sequence glyphs for glyphless characters.
+   See the comment of fill_glyph_string for arguments.
+   Value is the index of the first glyph not in S.  */
+
+
+static int
+fill_glyphless_glyph_string (struct glyph_string *s, int face_id,
+			     int start, int end, int overlaps)
+{
+  struct glyph *glyph, *last;
+  int voffset;
+
+  xassert (s->first_glyph->type == GLYPHLESS_GLYPH);
+  s->for_overlaps = overlaps;
+  glyph = s->row->glyphs[s->area] + start;
+  last = s->row->glyphs[s->area] + end;
+  voffset = glyph->voffset;
+  s->face = FACE_FROM_ID (s->f, face_id);
+  s->font = s->face->font;
+  s->nchars = 1;
+  s->width = glyph->pixel_width;
+  glyph++;
+  while (glyph < last
+	 && glyph->type == GLYPHLESS_GLYPH
+	 && glyph->voffset == voffset
+	 && glyph->face_id == face_id)
+    {
+      s->nchars++;
+      s->width += glyph->pixel_width;
+      glyph++;
+    }
+  s->ybase += voffset;
+  return glyph - s->row->glyphs[s->area];
+}
+
+
 /* Fill glyph string S from a sequence of character glyphs.
 
    FACE_ID is the face id of the string.  START is the index of the
@@ -21161,6 +21318,28 @@
   } while (0)
 
 
+/* Add a glyph string for a sequence of glyphless character's glyphs
+   to the list of strings between HEAD and TAIL.  The meanings of
+   arguments are the same as those of BUILD_CHAR_GLYPH_STRINGS.  */
+
+#define BUILD_GLYPHLESS_GLYPH_STRING(START, END, HEAD, TAIL, HL, X, LAST_X) \
+  do									    \
+    {									    \
+      int face_id;							    \
+      XChar2b *char2b;							    \
+									    \
+      face_id = (row)->glyphs[area][START].face_id;			    \
+									    \
+      s = (struct glyph_string *) alloca (sizeof *s);			    \
+      INIT_GLYPH_STRING (s, NULL, w, row, area, START, HL);		    \
+      append_glyph_string (&HEAD, &TAIL, s);				    \
+      s->x = (X);							    \
+      START = fill_glyphless_glyph_string (s, face_id, START, END,	    \
+					   overlaps);			    \
+    }									    \
+  while (0)
+
+
 /* Build a list of glyph strings between HEAD and TAIL for the glyphs
    of AREA of glyph row ROW on window W between indices START and END.
    HL overrides the face for drawing glyph strings, e.g. it is
@@ -21184,7 +21363,7 @@
 	      BUILD_CHAR_GLYPH_STRINGS (START, END, HEAD, TAIL,		\
 					HL, X, LAST_X);			\
 	      break;							\
-	      								\
+									\
 	    case COMPOSITE_GLYPH:					\
 	      if (first_glyph->u.cmp.automatic)				\
 		BUILD_GSTRING_GLYPH_STRING (START, END, HEAD, TAIL,	\
@@ -21193,21 +21372,26 @@
 		BUILD_COMPOSITE_GLYPH_STRING (START, END, HEAD, TAIL,	\
 					      HL, X, LAST_X);		\
 	      break;							\
-	      								\
+									\
 	    case STRETCH_GLYPH:						\
 	      BUILD_STRETCH_GLYPH_STRING (START, END, HEAD, TAIL,	\
 					  HL, X, LAST_X);		\
 	      break;							\
-	      								\
+									\
 	    case IMAGE_GLYPH:						\
 	      BUILD_IMAGE_GLYPH_STRING (START, END, HEAD, TAIL,		\
 					HL, X, LAST_X);			\
 	      break;							\
-	      								\
+									\
+	    case GLYPHLESS_GLYPH:					\
+	      BUILD_GLYPHLESS_GLYPH_STRING (START, END, HEAD, TAIL,	\
+					    HL, X, LAST_X);		\
+	      break;							\
+									\
 	    default:							\
 	      abort ();							\
 	    }								\
-	  								\
+									\
 	  if (s)							\
 	    {								\
 	      set_glyph_string_background_width (s, START, LAST_X);	\
@@ -21291,7 +21475,7 @@
   if (head && !overlaps && row->contains_overlapping_glyphs_p)
     {
       struct glyph_string *h, *t;
-      Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
+      Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
       int mouse_beg_col, mouse_end_col, check_mouse_face = 0;
       int dummy_x = 0;
 
@@ -21301,16 +21485,16 @@
 	{
 	  struct glyph_row *mouse_beg_row, *mouse_end_row;
 
-	  mouse_beg_row = MATRIX_ROW (w->current_matrix, dpyinfo->mouse_face_beg_row);
-	  mouse_end_row = MATRIX_ROW (w->current_matrix, dpyinfo->mouse_face_end_row);
+	  mouse_beg_row = MATRIX_ROW (w->current_matrix, hlinfo->mouse_face_beg_row);
+	  mouse_end_row = MATRIX_ROW (w->current_matrix, hlinfo->mouse_face_end_row);
 
 	  if (row >= mouse_beg_row && row <= mouse_end_row)
 	    {
 	      check_mouse_face = 1;
 	      mouse_beg_col = (row == mouse_beg_row)
-		? dpyinfo->mouse_face_beg_col : 0;
+		? hlinfo->mouse_face_beg_col : 0;
 	      mouse_end_col = (row == mouse_end_row)
-		? dpyinfo->mouse_face_end_col
+		? hlinfo->mouse_face_end_col
 		: row->used[TEXT_AREA];
 	    }
 	}
@@ -22103,6 +22287,229 @@
 }
 
 
+/* Append a glyph for a glyphless character to IT->glyph_row.  FACE_ID
+   is a face ID to be used for the glyph.  FOR_NO_FONT is nonzero if
+   and only if this is for a character for which no font was found.
+
+   If the display method (it->glyphless_method) is
+   GLYPHLESS_DISPLAY_ACRONYM or GLYPHLESS_DISPLAY_HEXA_CODE, LEN is a
+   length of the acronym or the hexadecimal string, UPPER_XOFF and
+   UPPER_YOFF are pixel offsets for the upper part of the string,
+   LOWER_XOFF and LOWER_YOFF are for the lower part.
+
+   For the other display methods, LEN through LOWER_YOFF are zero.  */
+
+static void
+append_glyphless_glyph (struct it *it, int face_id, int for_no_font, int len,
+			short upper_xoff, short upper_yoff,
+			short lower_xoff, short lower_yoff)
+{
+  struct glyph *glyph;
+  enum glyph_row_area area = it->area;
+
+  glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area];
+  if (glyph < it->glyph_row->glyphs[area + 1])
+    {
+      /* If the glyph row is reversed, we need to prepend the glyph
+	 rather than append it.  */
+      if (it->glyph_row->reversed_p && area == TEXT_AREA)
+	{
+	  struct glyph *g;
+
+	  /* Make room for the additional glyph.  */
+	  for (g = glyph - 1; g >= it->glyph_row->glyphs[area]; g--)
+	    g[1] = *g;
+	  glyph = it->glyph_row->glyphs[area];
+	}
+      glyph->charpos = CHARPOS (it->position);
+      glyph->object = it->object;
+      glyph->pixel_width = it->pixel_width;
+      glyph->ascent = it->ascent;
+      glyph->descent = it->descent;
+      glyph->voffset = it->voffset;
+      glyph->type = GLYPHLESS_GLYPH;
+      glyph->u.glyphless.method = it->glyphless_method;
+      glyph->u.glyphless.for_no_font = for_no_font;
+      glyph->u.glyphless.len = len;
+      glyph->u.glyphless.ch = it->c;
+      glyph->slice.glyphless.upper_xoff = upper_xoff;
+      glyph->slice.glyphless.upper_yoff = upper_yoff;
+      glyph->slice.glyphless.lower_xoff = lower_xoff;
+      glyph->slice.glyphless.lower_yoff = lower_yoff;
+      glyph->avoid_cursor_p = it->avoid_cursor_p;
+      glyph->multibyte_p = it->multibyte_p;
+      glyph->left_box_line_p = it->start_of_box_run_p;
+      glyph->right_box_line_p = it->end_of_box_run_p;
+      glyph->overlaps_vertically_p = (it->phys_ascent > it->ascent
+				      || it->phys_descent > it->descent);
+      glyph->padding_p = 0;
+      glyph->glyph_not_available_p = 0;
+      glyph->face_id = face_id;
+      glyph->font_type = FONT_TYPE_UNKNOWN;
+      if (it->bidi_p)
+	{
+	  glyph->resolved_level = it->bidi_it.resolved_level;
+	  if ((it->bidi_it.type & 7) != it->bidi_it.type)
+	    abort ();
+	  glyph->bidi_type = it->bidi_it.type;
+	}
+      ++it->glyph_row->used[area];
+    }
+  else
+    IT_EXPAND_MATRIX_WIDTH (it, area);
+}
+
+
+/* Produce a glyph for a glyphless character for iterator IT.
+   IT->glyphless_method specifies which method to use for displaying
+   the character.  See the description of enum
+   glyphless_display_method in dispextern.h for the detail.
+
+   FOR_NO_FONT is nonzero if and only if this is for a character for
+   which no font was found.  ACRONYM, if non-nil, is an acronym string
+   for the character.  */
+
+static void
+produce_glyphless_glyph (struct it *it, int for_no_font, Lisp_Object acronym)
+{
+  int face_id;
+  struct face *face;
+  struct font *font;
+  int base_width, base_height, width, height;
+  short upper_xoff, upper_yoff, lower_xoff, lower_yoff;
+  int len;
+
+  /* Get the metrics of the base font.  We always refer to the current
+     ASCII face.  */
+  face = FACE_FROM_ID (it->f, it->face_id)->ascii_face;
+  font = face->font ? face->font : FRAME_FONT (it->f);
+  it->ascent = FONT_BASE (font) + font->baseline_offset;
+  it->descent = FONT_DESCENT (font) - font->baseline_offset;
+  base_height = it->ascent + it->descent;
+  base_width = font->average_width;
+
+  /* Get a face ID for the glyph by utilizing a cache (the same way as
+     doen for `escape-glyph' in get_next_display_element).  */
+  if (it->f == last_glyphless_glyph_frame
+      && it->face_id == last_glyphless_glyph_face_id)
+    {
+      face_id = last_glyphless_glyph_merged_face_id;
+    }
+  else
+    {
+      /* Merge the `glyphless-char' face into the current face.  */
+      face_id = merge_faces (it->f, Qglyphless_char, 0, it->face_id);
+      last_glyphless_glyph_frame = it->f;
+      last_glyphless_glyph_face_id = it->face_id;
+      last_glyphless_glyph_merged_face_id = face_id;
+    }
+
+  if (it->glyphless_method == GLYPHLESS_DISPLAY_THIN_SPACE)
+    {
+      it->pixel_width = THIN_SPACE_WIDTH;
+      len = 0;
+      upper_xoff = upper_yoff = lower_xoff = lower_yoff = 0;
+    }
+  else if (it->glyphless_method == GLYPHLESS_DISPLAY_EMPTY_BOX)
+    {
+      width = CHAR_WIDTH (it->c);
+      if (width == 0)
+	width = 1;
+      else if (width > 4)
+	width = 4;
+      it->pixel_width = base_width * width;
+      len = 0;
+      upper_xoff = upper_yoff = lower_xoff = lower_yoff = 0;
+    }
+  else
+    {
+      char buf[7], *str;
+      unsigned int code[6];
+      int upper_len;
+      int ascent, descent;
+      struct font_metrics metrics_upper, metrics_lower;
+
+      face = FACE_FROM_ID (it->f, face_id);
+      font = face->font ? face->font : FRAME_FONT (it->f);
+      PREPARE_FACE_FOR_DISPLAY (it->f, face);
+
+      if (it->glyphless_method == GLYPHLESS_DISPLAY_ACRONYM)
+	{
+	  if (! STRINGP (acronym) && CHAR_TABLE_P (Vglyphless_char_display))
+	    acronym = CHAR_TABLE_REF (Vglyphless_char_display, it->c);
+	  str = STRINGP (acronym) ? (char *) SDATA (acronym) : "";
+	}
+      else
+	{
+	  xassert (it->glyphless_method == GLYPHLESS_DISPLAY_HEXA_CODE);
+	  sprintf (buf, "%0*X", it->c < 0x10000 ? 4 : 6, it->c);
+	  str = buf;
+	}
+      for (len = 0; str[len] && ASCII_BYTE_P (str[len]); len++)
+	code[len] = font->driver->encode_char (font, str[len]);
+      upper_len = (len + 1) / 2;
+      font->driver->text_extents (font, code, upper_len,
+				  &metrics_upper);
+      font->driver->text_extents (font, code + upper_len, len - upper_len,
+				  &metrics_lower);
+
+
+
+      /* +4 is for vertical bars of a box plus 1-pixel spaces at both side.  */
+      width = max (metrics_upper.width, metrics_lower.width) + 4;
+      upper_xoff = upper_yoff = 2; /* the typical case */
+      if (base_width >= width)
+	{
+	  /* Align the upper to the left, the lower to the right.  */
+	  it->pixel_width = base_width;
+	  lower_xoff = base_width - 2 - metrics_lower.width;
+	}
+      else
+	{
+	  /* Center the shorter one.  */
+	  it->pixel_width = width;
+	  if (metrics_upper.width >= metrics_lower.width)
+	    lower_xoff = (width - metrics_lower.width) / 2;
+	  else
+	    upper_xoff = (width - metrics_upper.width) / 2;
+	}
+  
+      /* +5 is for horizontal bars of a box plus 1-pixel spaces at
+	 top, bottom, and between upper and lower strings.  */
+      height = (metrics_upper.ascent + metrics_upper.descent
+		+ metrics_lower.ascent + metrics_lower.descent) + 5;
+      /* Center vertically.
+	 H:base_height, D:base_descent
+	 h:height, ld:lower_descent, la:lower_ascent, ud:upper_descent
+
+	 ascent = - (D - H/2 - h/2 + 1); "+ 1" for rounding up
+	 descent = D - H/2 + h/2;
+	 lower_yoff = descent - 2 - ld;
+	 upper_yoff = lower_yoff - la - 1 - ud;  */
+      ascent = - (it->descent - (base_height + height + 1) / 2);
+      descent = it->descent - (base_height - height) / 2;
+      lower_yoff = descent - 2 - metrics_lower.descent;
+      upper_yoff = (lower_yoff - metrics_lower.ascent - 1
+		    - metrics_upper.descent);
+      /* Don't make the height shorter than the base height. */
+      if (height > base_height)
+	{
+	  it->ascent = ascent;
+	  it->descent = descent;
+	}
+    }
+
+  it->phys_ascent = it->ascent;
+  it->phys_descent = it->descent;
+  if (it->glyph_row)
+    append_glyphless_glyph (it, face_id, for_no_font, len,
+			    upper_xoff, upper_yoff,
+			    lower_xoff, lower_yoff);
+  it->nglyphs = 1;
+  take_vertical_position_into_account (it);
+}
+
+
 /* RIF:
    Produce glyphs/get display metrics for the display element IT is
    loaded with.  See the description of struct it in dispextern.h
@@ -22120,28 +22527,24 @@
       XChar2b char2b;
       struct face *face = FACE_FROM_ID (it->f, it->face_id);
       struct font *font = face->font;
-      int font_not_found_p = font == NULL;
       struct font_metrics *pcm = NULL;
       int boff;			/* baseline offset */
 
-      if (font_not_found_p)
-	{
-	  /* When no suitable font found, display an empty box based
-	     on the metrics of the font of the default face (or what
-	     remapped).  */
-	  struct face *no_font_face
-	    = FACE_FROM_ID (it->f,
-			    NILP (Vface_remapping_alist) ? DEFAULT_FACE_ID
-			    : lookup_basic_face (it->f, DEFAULT_FACE_ID));
-	  font = no_font_face->font;
-	  boff = font->baseline_offset;
-	}
-      else
-	{
-	  boff = font->baseline_offset;
-	  if (font->vertical_centering)
-	    boff = VCENTER_BASELINE_OFFSET (font, it->f) - boff;
-	}
+      if (font == NULL)
+	{
+	  /* When no suitable font is found, display this character by
+	     the method specified in the first extra slot of
+	     Vglyphless_char_display.  */
+	  Lisp_Object acronym = lookup_glyphless_char_display (-1, it);
+
+	  xassert (it->what == IT_GLYPHLESS);
+	  produce_glyphless_glyph (it, 1, STRINGP (acronym) ? acronym : Qnil);
+	  goto done;
+	}
+
+      boff = font->baseline_offset;
+      if (font->vertical_centering)
+	boff = VCENTER_BASELINE_OFFSET (font, it->f) - boff;
 
       if (it->char_to_display != '\n' && it->char_to_display != '\t')
 	{
@@ -22161,8 +22564,7 @@
  	      it->descent = FONT_DESCENT (font) - boff;
  	    }
 
-	  if (! font_not_found_p
-	      && get_char_glyph_code (it->char_to_display, font, &char2b))
+	  if (get_char_glyph_code (it->char_to_display, font, &char2b))
 	    {
 	      pcm = get_per_char_metric (it->f, font, &char2b);
 	      if (pcm->width == 0
@@ -22752,11 +23154,14 @@
       if (it->glyph_row)
 	append_composite_glyph (it);
     }
+  else if (it->what == IT_GLYPHLESS)
+    produce_glyphless_glyph (it, 0, Qnil);
   else if (it->what == IT_IMAGE)
     produce_image_glyph (it);
   else if (it->what == IT_STRETCH)
     produce_stretch_glyph (it);
 
+ done:
   /* Accumulate dimensions.  Note: can't assume that it->descent > 0
      because this isn't true for images with `:ascent 100'.  */
   xassert (it->ascent >= 0 && it->descent >= 0);
@@ -23028,6 +23433,8 @@
 }
 
 
+#ifdef HAVE_WINDOW_SYSTEM
+
 /* Return the cursor we want to be displayed in window W.  Return
    width of bar/hbar cursor through WIDTH arg.  Return with
    ACTIVE_CURSOR arg set to 1 if cursor in window W is `active'
@@ -23073,10 +23480,7 @@
 
   /* Detect a nonselected window or nonselected frame.  */
   else if (w != XWINDOW (f->selected_window)
-#ifdef HAVE_WINDOW_SYSTEM
-	   || f != FRAME_X_DISPLAY_INFO (f)->x_highlight_frame
-#endif
-	   )
+	   || f != FRAME_X_DISPLAY_INFO (f)->x_highlight_frame)
     {
       *active_cursor = 0;
 
@@ -23117,7 +23521,6 @@
   /* Use normal cursor if not blinked off.  */
   if (!w->cursor_off_p)
     {
-#ifdef HAVE_WINDOW_SYSTEM
       if (glyph != NULL && glyph->type == IMAGE_GLYPH)
 	{
 	  if (cursor_type == FILLED_BOX_CURSOR)
@@ -23145,7 +23548,6 @@
 	      cursor_type = HOLLOW_BOX_CURSOR;
 	    }
       }
-#endif
       return cursor_type;
     }
 
@@ -23187,8 +23589,6 @@
 }
 
 
-#ifdef HAVE_WINDOW_SYSTEM
-
 /* Notice when the text cursor of window W has been completely
    overwritten by a drawing operation that outputs glyphs in AREA
    starting at X0 and ending at X1 in the line starting at Y0 and
@@ -23354,7 +23754,7 @@
 erase_phys_cursor (struct window *w)
 {
   struct frame *f = XFRAME (w->frame);
-  Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
+  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
   int hpos = w->phys_cursor.hpos;
   int vpos = w->phys_cursor.vpos;
   int mouse_face_here_p = 0;
@@ -23410,14 +23810,8 @@
 
   /* 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))
+  if (! NILP (hlinfo->mouse_face_window)
+      && 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.  */
@@ -23608,30 +24002,50 @@
     update_window_cursor (w, 0);
 }
 
+#endif /* HAVE_WINDOW_SYSTEM */
+
+/* Implementation of draw_row_with_mouse_face for GUI sessions, GPM,
+   and MSDOS.  */
+void
+draw_row_with_mouse_face (struct window *w, int start_x, struct glyph_row *row,
+			  int start_hpos, int end_hpos,
+			  enum draw_glyphs_face draw)
+{
+#ifdef HAVE_WINDOW_SYSTEM
+  if (FRAME_WINDOW_P (XFRAME (w->frame)))
+    {
+      draw_glyphs (w, start_x, row, TEXT_AREA, start_hpos, end_hpos, draw, 0);
+      return;
+    }
+#endif
+#if defined (HAVE_GPM) || defined (MSDOS)
+  tty_draw_row_with_mouse_face (w, row, start_hpos, end_hpos, draw);
+#endif
+}
 
 /* EXPORT:
    Display the active region described by mouse_face_* according to DRAW.  */
 
 void
-show_mouse_face (Display_Info *dpyinfo, enum draw_glyphs_face draw)
-{
-  struct window *w = XWINDOW (dpyinfo->mouse_face_window);
+show_mouse_face (Mouse_HLInfo *hlinfo, enum draw_glyphs_face draw)
+{
+  struct window *w = XWINDOW (hlinfo->mouse_face_window);
   struct frame *f = XFRAME (WINDOW_FRAME (w));
 
   if (/* If window is in the process of being destroyed, don't bother
 	 to do anything.  */
       w->current_matrix != NULL
       /* Don't update mouse highlight if hidden */
-      && (draw != DRAW_MOUSE_FACE || !dpyinfo->mouse_face_hidden)
+      && (draw != DRAW_MOUSE_FACE || !hlinfo->mouse_face_hidden)
       /* Recognize when we are called to operate on rows that don't exist
 	 anymore.  This can happen when a window is split.  */
-      && dpyinfo->mouse_face_end_row < w->current_matrix->nrows)
+      && hlinfo->mouse_face_end_row < w->current_matrix->nrows)
     {
       int phys_cursor_on_p = w->phys_cursor_on_p;
       struct glyph_row *row, *first, *last;
 
-      first = MATRIX_ROW (w->current_matrix, dpyinfo->mouse_face_beg_row);
-      last = MATRIX_ROW (w->current_matrix, dpyinfo->mouse_face_end_row);
+      first = MATRIX_ROW (w->current_matrix, hlinfo->mouse_face_beg_row);
+      last = MATRIX_ROW (w->current_matrix, hlinfo->mouse_face_end_row);
 
       for (row = first; row <= last && row->enabled_p; ++row)
 	{
@@ -23640,8 +24054,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 = hlinfo->mouse_face_beg_col;
+		  start_x = hlinfo->mouse_face_beg_x;
+		}
+	      else if (row == last)
+		{
+		  start_hpos = hlinfo->mouse_face_end_col;
+		  start_x = hlinfo->mouse_face_end_x;
+		}
+	      else
+		{
+		  start_hpos = 0;
+		  start_x = 0;
+		}
+	    }
+	  else if (row->reversed_p && row == last)
+	    {
+	      start_hpos = hlinfo->mouse_face_end_col;
+	      start_x = hlinfo->mouse_face_end_x;
 	    }
 	  else
 	    {
@@ -23650,7 +24086,20 @@
 	    }
 
 	  if (row == last)
-	    end_hpos = dpyinfo->mouse_face_end_col;
+	    {
+	      if (!row->reversed_p)
+		end_hpos = hlinfo->mouse_face_end_col;
+	      else if (row == first)
+		end_hpos = hlinfo->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 = hlinfo->mouse_face_beg_col;
 	  else
 	    {
 	      end_hpos = row->used[TEXT_AREA];
@@ -23660,18 +24109,19 @@
 
 	  if (end_hpos > start_hpos)
 	    {
-	      draw_glyphs (w, start_x, row, TEXT_AREA,
-			   start_hpos, end_hpos,
-			   draw, 0);
+	      draw_row_with_mouse_face (w, start_x, row,
+					start_hpos, end_hpos, draw);
 
 	      row->mouse_face_p
 		= draw == DRAW_MOUSE_FACE || draw == DRAW_IMAGE_RAISED;
 	    }
 	}
 
+#ifdef HAVE_WINDOW_SYSTEM
       /* When we've written over the cursor, arrange for it to
 	 be displayed again.  */
-      if (phys_cursor_on_p && !w->phys_cursor_on_p)
+      if (FRAME_WINDOW_P (f)
+	  && phys_cursor_on_p && !w->phys_cursor_on_p)
 	{
 	  BLOCK_INPUT;
 	  display_and_set_cursor (w, 1,
@@ -23679,15 +24129,22 @@
 				  w->phys_cursor.x, w->phys_cursor.y);
 	  UNBLOCK_INPUT;
 	}
-    }
-
+#endif	/* HAVE_WINDOW_SYSTEM */
+    }
+
+#ifdef HAVE_WINDOW_SYSTEM
   /* Change the mouse cursor.  */
-  if (draw == DRAW_NORMAL_TEXT && !EQ (dpyinfo->mouse_face_window, f->tool_bar_window))
-    FRAME_RIF (f)->define_frame_cursor (f, FRAME_X_OUTPUT (f)->text_cursor);
-  else if (draw == DRAW_MOUSE_FACE)
-    FRAME_RIF (f)->define_frame_cursor (f, FRAME_X_OUTPUT (f)->hand_cursor);
-  else
-    FRAME_RIF (f)->define_frame_cursor (f, FRAME_X_OUTPUT (f)->nontext_cursor);
+  if (FRAME_WINDOW_P (f))
+    {
+      if (draw == DRAW_NORMAL_TEXT
+	  && !EQ (hlinfo->mouse_face_window, f->tool_bar_window))
+	FRAME_RIF (f)->define_frame_cursor (f, FRAME_X_OUTPUT (f)->text_cursor);
+      else if (draw == DRAW_MOUSE_FACE)
+	FRAME_RIF (f)->define_frame_cursor (f, FRAME_X_OUTPUT (f)->hand_cursor);
+      else
+	FRAME_RIF (f)->define_frame_cursor (f, FRAME_X_OUTPUT (f)->nontext_cursor);
+    }
+#endif	/* HAVE_WINDOW_SYSTEM */
 }
 
 /* EXPORT:
@@ -23696,23 +24153,70 @@
    face was actually drawn unhighlighted.  */
 
 int
-clear_mouse_face (Display_Info *dpyinfo)
+clear_mouse_face (Mouse_HLInfo *hlinfo)
 {
   int cleared = 0;
 
-  if (!dpyinfo->mouse_face_hidden && !NILP (dpyinfo->mouse_face_window))
-    {
-      show_mouse_face (dpyinfo, DRAW_NORMAL_TEXT);
+  if (!hlinfo->mouse_face_hidden && !NILP (hlinfo->mouse_face_window))
+    {
+      show_mouse_face (hlinfo, DRAW_NORMAL_TEXT);
       cleared = 1;
     }
 
-  dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1;
-  dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
-  dpyinfo->mouse_face_window = Qnil;
-  dpyinfo->mouse_face_overlay = Qnil;
+  hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
+  hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
+  hlinfo->mouse_face_window = Qnil;
+  hlinfo->mouse_face_overlay = Qnil;
   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)
+{
+  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (XFRAME (w->frame));
+
+  /* Quickly resolve the easy cases.  */
+  if (!(WINDOWP (hlinfo->mouse_face_window)
+	&& XWINDOW (hlinfo->mouse_face_window) == w))
+    return 0;
+  if (vpos < hlinfo->mouse_face_beg_row
+      || vpos > hlinfo->mouse_face_end_row)
+    return 0;
+  if (vpos > hlinfo->mouse_face_beg_row
+      && vpos < hlinfo->mouse_face_end_row)
+    return 1;
+
+  if (!MATRIX_ROW (w->current_matrix, vpos)->reversed_p)
+    {
+      if (hlinfo->mouse_face_beg_row == hlinfo->mouse_face_end_row)
+	{
+	  if (hlinfo->mouse_face_beg_col <= hpos && hpos < hlinfo->mouse_face_end_col)
+	    return 1;
+	}
+      else if ((vpos == hlinfo->mouse_face_beg_row
+		&& hpos >= hlinfo->mouse_face_beg_col)
+	       || (vpos == hlinfo->mouse_face_end_row
+		   && hpos < hlinfo->mouse_face_end_col))
+	return 1;
+    }
+  else
+    {
+       if (hlinfo->mouse_face_beg_row == hlinfo->mouse_face_end_row)
+	{
+	  if (hlinfo->mouse_face_end_col < hpos && hpos <= hlinfo->mouse_face_beg_col)
+	    return 1;
+	}
+      else if ((vpos == hlinfo->mouse_face_beg_row
+		&& hpos <= hlinfo->mouse_face_beg_col)
+	       || (vpos == hlinfo->mouse_face_end_row
+		   && hpos > hlinfo->mouse_face_end_col))
+	return 1;
+    }
+  return 0;
+}
+
 
 /* EXPORT:
    Non-zero if physical cursor of window W is within mouse face.  */
@@ -23720,32 +24224,135 @@
 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;
-}
-
-
-
-
-/* This function sets the mouse_face_* elements of DPYINFO, assuming
+  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 HLINFO, assuming
    the mouse cursor is on a glyph with buffer charpos MOUSE_CHARPOS in
    window WINDOW.  START_CHARPOS and END_CHARPOS are buffer positions
    for the overlay or run of text properties specifying the mouse
@@ -23756,7 +24363,7 @@
 
 static void
 mouse_face_from_buffer_pos (Lisp_Object window,
-			    Display_Info *dpyinfo,
+			    Mouse_HLInfo *hlinfo,
 			    EMACS_INT mouse_charpos,
 			    EMACS_INT start_charpos,
 			    EMACS_INT end_charpos,
@@ -23766,84 +24373,42 @@
 {
   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));
-      dpyinfo->mouse_face_past_end = 1;
+  /* 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));
+      hlinfo->mouse_face_past_end = 1;
     }
   else if (!NILP (after_string))
     {
@@ -23852,80 +24417,269 @@
       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;
+    }
+
+  hlinfo->mouse_face_beg_y = r1->y;
+  hlinfo->mouse_face_beg_row = MATRIX_ROW_VPOS (r1, w->current_matrix);
+  hlinfo->mouse_face_end_y = r2->y;
+  hlinfo->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;
+	}
+      hlinfo->mouse_face_beg_x = x;
+      hlinfo->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;
+      hlinfo->mouse_face_beg_x = x;
+      hlinfo->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_window = window;
-  dpyinfo->mouse_face_face_id
+
+      hlinfo->mouse_face_end_x = x;
+      hlinfo->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;
+	}
+      hlinfo->mouse_face_end_x = x;
+      hlinfo->mouse_face_end_col = end - r2->glyphs[TEXT_AREA];
+    }
+
+  hlinfo->mouse_face_window = window;
+  hlinfo->mouse_face_face_id
     = face_at_buffer_position (w, mouse_charpos, 0, 0, &ignore,
 			       mouse_charpos + 1,
-			       !dpyinfo->mouse_face_hidden, -1);
-  show_mouse_face (dpyinfo, DRAW_MOUSE_FACE);
-}
-
+			       !hlinfo->mouse_face_hidden, -1);
+  show_mouse_face (hlinfo, 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 +24757,132 @@
 
   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 HLINFO's mouse_face_*
+   members the pixel and column/row coordinates of those glyphs.  */
+
+static void
+mouse_face_from_string_pos (struct window *w, Mouse_HLInfo *hlinfo,
+			    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)
+	      {
+		hlinfo->mouse_face_beg_row = r - w->current_matrix->rows;
+		hlinfo->mouse_face_beg_y = r->y;
+		hlinfo->mouse_face_beg_col = g - r->glyphs[TEXT_AREA];
+		hlinfo->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)
+	      {
+		hlinfo->mouse_face_beg_row = r - w->current_matrix->rows;
+		hlinfo->mouse_face_beg_y = r->y;
+		hlinfo->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;
+		hlinfo->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.  */
+  hlinfo->mouse_face_end_row = r - w->current_matrix->rows;
+  hlinfo->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;
+      hlinfo->mouse_face_end_col = e - g;
+
+      for (gx = r->x; g < e; ++g)
+	gx += g->pixel_width;
+      hlinfo->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;
+	}
+      hlinfo->mouse_face_end_col = e - r->glyphs[TEXT_AREA];
+      hlinfo->mouse_face_end_x = gx;
+    }
+}
+
+#ifdef HAVE_WINDOW_SYSTEM
 
 /* See if position X, Y is within a hot-spot of an image.  */
 
@@ -24175,6 +25054,8 @@
     FRAME_RIF (f)->define_frame_cursor (f, cursor);
 }
 
+#endif	/* HAVE_WINDOW_SYSTEM */
+
 /* Take proper action when mouse has moved to the mode or header line
    or marginal area AREA of window W, x-position X and y-position Y.
    X is relative to the start of the text display area of W, so the
@@ -24187,8 +25068,11 @@
 {
   struct window *w = XWINDOW (window);
   struct frame *f = XFRAME (w->frame);
-  Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
-  Cursor cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
+  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
+#ifdef HAVE_WINDOW_SYSTEM
+  Display_Info *dpyinfo;
+#endif
+  Cursor cursor = No_Cursor;
   Lisp_Object pointer = Qnil;
   int dx, dy, width, height;
   EMACS_INT charpos;
@@ -24205,6 +25089,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 +25098,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,12 +25116,15 @@
   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);
     }
 
   help = Qnil;
 
+#ifdef HAVE_WINDOW_SYSTEM
   if (IMAGEP (object))
     {
       Lisp_Object image_map, hotspot;
@@ -24272,6 +25161,7 @@
       if (NILP (pointer))
 	pointer = Fplist_get (XCDR (object), QCpointer);
     }
+#endif	/* HAVE_WINDOW_SYSTEM */
 
   if (STRINGP (string))
     {
@@ -24291,19 +25181,27 @@
 	    }
 	}
 
-      if (NILP (pointer))
-	pointer = Fget_text_property (pos, Qpointer, string);
-
-     /* Change the mouse pointer according to what is under X/Y.  */
-      if (NILP (pointer) && ((area == ON_MODE_LINE) || (area == ON_HEADER_LINE)))
-	{
-	  Lisp_Object map;
-	  map = Fget_text_property (pos, Qlocal_map, string);
-	  if (!KEYMAPP (map))
-	    map = Fget_text_property (pos, Qkeymap, string);
-	  if (!KEYMAPP (map))
-	    cursor = dpyinfo->vertical_scroll_bar_cursor;
-	}
+#ifdef HAVE_WINDOW_SYSTEM
+      if (FRAME_WINDOW_P (f))
+	{
+	  dpyinfo = FRAME_X_DISPLAY_INFO (f);
+	  cursor  = FRAME_X_OUTPUT (f)->nontext_cursor;
+	  if (NILP (pointer))
+	    pointer = Fget_text_property (pos, Qpointer, string);
+
+	  /* Change the mouse pointer according to what is under X/Y.  */
+	  if (NILP (pointer)
+	      && ((area == ON_MODE_LINE) || (area == ON_HEADER_LINE)))
+	    {
+	      Lisp_Object map;
+	      map = Fget_text_property (pos, Qlocal_map, string);
+	      if (!KEYMAPP (map))
+		map = Fget_text_property (pos, Qkeymap, string);
+	      if (!KEYMAPP (map))
+		cursor = dpyinfo->vertical_scroll_bar_cursor;
+	    }
+	}
+#endif
 
      /* Change the mouse face according to what is under X/Y.  */
       mouse_face = Fget_text_property (pos, Qmouse_face, string);
@@ -24318,102 +25216,128 @@
 	  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 ( EQ (window, dpyinfo->mouse_face_window)
-	       && dpyinfo->mouse_face_beg_col <= vpos
-	       && vpos < dpyinfo->mouse_face_end_col
-	       && dpyinfo->mouse_face_beg_row == hpos )
+	  /* If GLYPH's position is included in the region that is
+	     already drawn in mouse face, we have nothing to do.  */
+	  if ( EQ (window, hlinfo->mouse_face_window)
+	       && (!row->reversed_p
+		   ? (hlinfo->mouse_face_beg_col <= hpos
+		      && hpos < hlinfo->mouse_face_end_col)
+		   /* In R2L rows we swap BEG and END, see below.  */
+		   : (hlinfo->mouse_face_end_col <= hpos
+		      && hpos < hlinfo->mouse_face_beg_col))
+	       && hlinfo->mouse_face_beg_row == vpos )
 	    return;
 
-	  if (clear_mouse_face (dpyinfo))
+	  if (clear_mouse_face (hlinfo))
 	    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;
-
-	  dpyinfo->mouse_face_past_end = 0;
-	  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);
-	  show_mouse_face (dpyinfo, DRAW_MOUSE_FACE);
+	  if (!row->reversed_p)
+	    {
+	      hlinfo->mouse_face_beg_col = hpos;
+	      hlinfo->mouse_face_beg_x   = original_x_pixel
+					    - (total_pixel_width + dx);
+	      hlinfo->mouse_face_end_col = hpos + gseq_length;
+	      hlinfo->mouse_face_end_x   = 0;
+	    }
+	  else
+	    {
+	      /* In R2L rows, show_mouse_face expects BEG and END
+		 coordinates to be swapped.  */
+	      hlinfo->mouse_face_end_col = hpos;
+	      hlinfo->mouse_face_end_x   = original_x_pixel
+					    - (total_pixel_width + dx);
+	      hlinfo->mouse_face_beg_col = hpos + gseq_length;
+	      hlinfo->mouse_face_beg_x   = 0;
+	    }
+
+	  hlinfo->mouse_face_beg_row  = vpos;
+	  hlinfo->mouse_face_end_row  = hlinfo->mouse_face_beg_row;
+	  hlinfo->mouse_face_beg_y    = 0;
+	  hlinfo->mouse_face_end_y    = 0;
+	  hlinfo->mouse_face_past_end = 0;
+	  hlinfo->mouse_face_window   = window;
+
+	  hlinfo->mouse_face_face_id = face_at_string_position (w, string,
+								charpos,
+								0, 0, 0,
+								&ignore,
+								glyph->face_id,
+								1);
+	  show_mouse_face (hlinfo, DRAW_MOUSE_FACE);
 
 	  if (NILP (pointer))
 	    pointer = Qhand;
 	}
       else if ((area == ON_MODE_LINE) || (area == ON_HEADER_LINE))
-	clear_mouse_face (dpyinfo);
-    }
-  define_frame_cursor1 (f, cursor, pointer);
+	clear_mouse_face (hlinfo);
+    }
+#ifdef HAVE_WINDOW_SYSTEM
+  if (FRAME_WINDOW_P (f))
+    define_frame_cursor1 (f, cursor, pointer);
+#endif
 }
 
 
@@ -24426,7 +25350,7 @@
 void
 note_mouse_highlight (struct frame *f, int x, int y)
 {
-  Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
+  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
   enum window_part part;
   Lisp_Object window;
   struct window *w;
@@ -24435,7 +25359,7 @@
   struct buffer *b;
 
   /* When a menu is active, don't highlight because this looks odd.  */
-#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS)
+#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS) || defined (MSDOS)
   if (popup_activated ())
     return;
 #endif
@@ -24445,16 +25369,16 @@
       || f->pointer_invisible)
     return;
 
-  dpyinfo->mouse_face_mouse_x = x;
-  dpyinfo->mouse_face_mouse_y = y;
-  dpyinfo->mouse_face_mouse_frame = f;
-
-  if (dpyinfo->mouse_face_defer)
+  hlinfo->mouse_face_mouse_x = x;
+  hlinfo->mouse_face_mouse_y = y;
+  hlinfo->mouse_face_mouse_frame = f;
+
+  if (hlinfo->mouse_face_defer)
     return;
 
   if (gc_in_progress)
     {
-      dpyinfo->mouse_face_deferred_gc = 1;
+      hlinfo->mouse_face_deferred_gc = 1;
       return;
     }
 
@@ -24463,10 +25387,10 @@
 
   /* If we were displaying active text in another window, clear that.
      Also clear if we move out of text area in same window.  */
-  if (! EQ (window, dpyinfo->mouse_face_window)
+  if (! EQ (window, hlinfo->mouse_face_window)
       || (part != ON_TEXT && part != ON_MODE_LINE && part != ON_HEADER_LINE
-	  && !NILP (dpyinfo->mouse_face_window)))
-    clear_mouse_face (dpyinfo);
+	  && !NILP (hlinfo->mouse_face_window)))
+    clear_mouse_face (hlinfo);
 
   /* Not on a window -> return.  */
   if (!WINDOWP (window))
@@ -24479,6 +25403,7 @@
   w = XWINDOW (window);
   frame_to_window_pixel_xy (w, &x, &y);
 
+#ifdef HAVE_WINDOW_SYSTEM
   /* Handle tool-bar window differently since it doesn't display a
      buffer.  */
   if (EQ (window, f->tool_bar_window))
@@ -24486,6 +25411,7 @@
       note_tool_bar_highlight (f, x, y);
       return;
     }
+#endif
 
   /* Mouse is on the mode, header line or margin?  */
   if (part == ON_MODE_LINE || part == ON_HEADER_LINE
@@ -24495,6 +25421,7 @@
       return;
     }
 
+#ifdef HAVE_WINDOW_SYSTEM
   if (part == ON_VERTICAL_BORDER)
     {
       cursor = FRAME_X_OUTPUT (f)->horizontal_drag_cursor;
@@ -24505,6 +25432,7 @@
     cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
   else
     cursor = FRAME_X_OUTPUT (f)->text_cursor;
+#endif
 
   /* Are we in a window whose display is up to date?
      And verify the buffer's text has not changed.  */
@@ -24528,6 +25456,7 @@
       /* Find the glyph under X/Y.  */
       glyph = x_y_to_hpos_vpos (w, x, y, &hpos, &vpos, &dx, &dy, &area);
 
+#ifdef HAVE_WINDOW_SYSTEM
       /* Look for :pointer property on image.  */
       if (glyph != NULL && glyph->type == IMAGE_GLYPH)
 	{
@@ -24569,21 +25498,38 @@
 		pointer = Fplist_get (XCDR (img->spec), QCpointer);
 	    }
 	}
+#endif	/* HAVE_WINDOW_SYSTEM */
 
       /* Clear mouse face if X/Y not over text.  */
       if (glyph == NULL
 	  || area != TEXT_AREA
-	  || !MATRIX_ROW (w->current_matrix, vpos)->displays_text_p)
-	{
-	  if (clear_mouse_face (dpyinfo))
+	  || !MATRIX_ROW (w->current_matrix, vpos)->displays_text_p
+	  /* Glyph's OBJECT is an integer for glyphs inserted by the
+	     display engine for its internal purposes, like truncation
+	     and continuation glyphs and blanks beyond the end of
+	     line's text on text terminals.  If we are over such a
+	     glyph, we are not over any text.  */
+	  || INTEGERP (glyph->object)
+	  /* 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 (hlinfo))
 	    cursor = No_Cursor;
-	  if (NILP (pointer))
+#ifdef HAVE_WINDOW_SYSTEM
+	  if (FRAME_WINDOW_P (f) && NILP (pointer))
 	    {
 	      if (area != TEXT_AREA)
 		cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
 	      else
 		pointer = Vvoid_text_area_pointer;
 	    }
+#endif
 	  goto set_cursor;
 	}
 
@@ -24618,14 +25564,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;
@@ -24636,8 +25575,8 @@
 	     the one we are currently highlighting, we have to
 	     check if we enter the overlapping overlay, and then
 	     highlight only that.  */
-	  || (OVERLAYP (dpyinfo->mouse_face_overlay)
-	      && mouse_face_overlay_overlaps (dpyinfo->mouse_face_overlay)))
+	  || (OVERLAYP (hlinfo->mouse_face_overlay)
+	      && mouse_face_overlay_overlaps (hlinfo->mouse_face_overlay)))
 	{
 	  /* Find the highest priority overlay with a mouse-face.  */
 	  overlay = Qnil;
@@ -24650,12 +25589,12 @@
 
 	  /* If we're highlighting the same overlay as before, there's
 	     no need to do that again.  */
-	  if (!NILP (overlay) && EQ (overlay, dpyinfo->mouse_face_overlay))
+	  if (!NILP (overlay) && EQ (overlay, hlinfo->mouse_face_overlay))
 	    goto check_help_echo;
-	  dpyinfo->mouse_face_overlay = overlay;
+	  hlinfo->mouse_face_overlay = overlay;
 
 	  /* Clear the display of the old active region, if any.  */
-	  if (clear_mouse_face (dpyinfo))
+	  if (clear_mouse_face (hlinfo))
 	    cursor = No_Cursor;
 
 	  /* If no overlay applies, get a text property.  */
@@ -24679,23 +25618,14 @@
 		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);
-	      dpyinfo->mouse_face_past_end = 0;
-	      dpyinfo->mouse_face_window = window;
-	      dpyinfo->mouse_face_face_id
+	      mouse_face_from_string_pos (w, hlinfo, object,
+					  XINT (b), XINT (e));
+	      hlinfo->mouse_face_past_end = 0;
+	      hlinfo->mouse_face_window = window;
+	      hlinfo->mouse_face_face_id
 		= face_at_string_position (w, object, pos, 0, 0, 0, &ignore,
 					   glyph->face_id, 1);
-	      show_mouse_face (dpyinfo, DRAW_MOUSE_FACE);
+	      show_mouse_face (hlinfo, DRAW_MOUSE_FACE);
 	      cursor = No_Cursor;
 	    }
 	  else
@@ -24729,17 +25659,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
@@ -24754,7 +25700,7 @@
 		      if (!STRINGP (after_string))  after_string = Qnil;
 		    }
 
-		  mouse_face_from_buffer_pos (window, dpyinfo, pos,
+		  mouse_face_from_buffer_pos (window, hlinfo, pos,
 					      XFASTINT (before),
 					      XFASTINT (after),
 					      before_string, after_string,
@@ -24833,8 +25779,9 @@
 	  }
       }
 
+#ifdef HAVE_WINDOW_SYSTEM
       /* Look for a `pointer' property.  */
-      if (NILP (pointer))
+      if (FRAME_WINDOW_P (f) && NILP (pointer))
 	{
 	  /* Check overlays first.  */
 	  for (i = noverlays - 1; i >= 0 && NILP (pointer); --i)
@@ -24873,6 +25820,7 @@
 					      Qpointer, object);
 	    }
 	}
+#endif	/* HAVE_WINDOW_SYSTEM */
 
       BEGV = obegv;
       ZV = ozv;
@@ -24881,7 +25829,14 @@
 
  set_cursor:
 
-  define_frame_cursor1 (f, cursor, pointer);
+#ifdef HAVE_WINDOW_SYSTEM
+  if (FRAME_WINDOW_P (f))
+    define_frame_cursor1 (f, cursor, pointer);
+#else
+  /* This is here to prevent a compiler error, about "label at end of
+     compound statement".  */
+  return;
+#endif
 }
 
 
@@ -24893,13 +25848,13 @@
 void
 x_clear_window_mouse_face (struct window *w)
 {
-  Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (XFRAME (w->frame));
+  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (XFRAME (w->frame));
   Lisp_Object window;
 
   BLOCK_INPUT;
   XSETWINDOW (window, w);
-  if (EQ (window, dpyinfo->mouse_face_window))
-    clear_mouse_face (dpyinfo);
+  if (EQ (window, hlinfo->mouse_face_window))
+    clear_mouse_face (hlinfo);
   UNBLOCK_INPUT;
 }
 
@@ -24912,19 +25867,17 @@
 cancel_mouse_face (struct frame *f)
 {
   Lisp_Object window;
-  Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
-
-  window = dpyinfo->mouse_face_window;
+  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
+
+  window = hlinfo->mouse_face_window;
   if (! NILP (window) && XFRAME (XWINDOW (window)->frame) == f)
     {
-      dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1;
-      dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
-      dpyinfo->mouse_face_window = Qnil;
-    }
-}
-
-
-#endif /* HAVE_WINDOW_SYSTEM */
+      hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
+      hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
+      hlinfo->mouse_face_window = Qnil;
+    }
+}
+
 
 
 /***********************************************************************
@@ -25382,12 +26335,12 @@
      focus-follows-mouse with delayed raise.  --jason 2001-10-12  */
   if (mouse_face_overwritten_p && !FRAME_GARBAGED_P (f))
     {
-      Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
-      if (f == dpyinfo->mouse_face_mouse_frame)
-	{
-	  int x = dpyinfo->mouse_face_mouse_x;
-	  int y = dpyinfo->mouse_face_mouse_y;
-	  clear_mouse_face (dpyinfo);
+      Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
+      if (f == hlinfo->mouse_face_mouse_frame)
+	{
+	  int x = hlinfo->mouse_face_mouse_x;
+	  int y = hlinfo->mouse_face_mouse_y;
+	  clear_mouse_face (hlinfo);
 	  note_mouse_highlight (f, x, y);
 	}
     }
@@ -25974,7 +26927,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,16 +27044,46 @@
   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;
   hourglass_shown_p = 0;
+
+  DEFSYM (Qglyphless_char, "glyphless-char");
+  DEFSYM (Qhexa_code, "hexa-code");
+  DEFSYM (Qempty_box, "empty-box");
+  DEFSYM (Qthin_space, "thin-space");
+  DEFSYM (Qzero_width, "zero-width");
+
+  DEFSYM (Qglyphless_char_display, "glyphless-char-display");
+  /* Intern this now in case it isn't already done.
+     Setting this variable twice is harmless.
+     But don't staticpro it here--that is done in alloc.c.  */
+  Qchar_table_extra_slots = intern_c_string ("char-table-extra-slots");
+  Fput (Qglyphless_char_display, Qchar_table_extra_slots, make_number (1));
+
+  DEFVAR_LISP ("glyphless-char-display", &Vglyphless_char_display,
+	       doc: /* Char-table to control displaying of glyphless characters.
+Each element, if non-nil, is an ASCII acronym string (displayed in a box)
+or one of these symbols:
+  hexa-code: display with hexadecimal character code in a box
+  empty-box: display with an empty box
+  thin-space: display with 1-pixel width space
+  zero-width: don't display
+
+It has one extra slot to control the display of a character for which
+no font is found.  The value of the slot is `hexa-code' or `empty-box'.
+The default is `empty-box'.  */);
+  Vglyphless_char_display = Fmake_char_table (Qglyphless_char_display, Qnil);
+  Fset_char_table_extra_slot (Vglyphless_char_display, make_number (0),
+			      Qempty_box);
 }
 
 
@@ -26216,5 +27201,3 @@
 }
 #endif /* ! WINDOWSNT  */
 
-/* arch-tag: eacc864d-bb6a-4b74-894a-1a4399a1358b
-   (do not change this comment) */
--- a/src/xfaces.c	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/xfaces.c	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/xfns.c	Mon Nov 08 14:19:54 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
@@ -3075,25 +3078,11 @@
 static void
 set_machine_and_pid_properties (struct frame *f)
 {
-  /* See the above comment "Note: Encoding strategy".  */
-  XTextProperty text;
-  int bytes, stringp;
-  int do_free_text_value = 0;
   long pid = (long) getpid ();
 
-  text.value = x_encode_text (Vsystem_name,
-                              Qcompound_text, 0, &bytes, &stringp,
-                              &do_free_text_value);
-  text.encoding = (stringp ? XA_STRING
-                   : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
-  text.format = 8;
-  text.nitems = bytes;
-  XSetWMClientMachine (FRAME_X_DISPLAY (f),
-                       FRAME_OUTER_WINDOW (f),
-                       &text);
-  if (do_free_text_value)
-    xfree (text.value);
-
+  /* This will set WM_CLIENT_MACHINE and WM_LOCALE_NAME.  */
+  XSetWMProperties (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), NULL, NULL,
+                    NULL, 0, NULL, NULL, NULL);
   XChangeProperty (FRAME_X_DISPLAY (f),
                    FRAME_OUTER_WINDOW (f),
                    XInternAtom (FRAME_X_DISPLAY (f),
@@ -3578,7 +3567,8 @@
 
 
 DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
-       doc: /* Internal function called by `color-defined-p', which see.  */)
+       doc: /* Internal function called by `color-defined-p', which see
+.\(Note that the Nextstep version of this function ignores FRAME.)  */)
   (Lisp_Object color, Lisp_Object frame)
 {
   XColor foo;
@@ -4096,11 +4086,12 @@
 
 DEFUN ("x-open-connection", Fx_open_connection, Sx_open_connection,
        1, 3, 0,
-       doc: /* Open a connection to an X server.
+       doc: /* Open a connection to a display server.
 DISPLAY is the name of the display to connect to.
 Optional second arg XRM-STRING is a string of resources in xrdb format.
 If the optional third arg MUST-SUCCEED is non-nil,
-terminate Emacs if we can't open the connection.  */)
+terminate Emacs if we can't open the connection.
+\(In the Nextstep version, the last two arguments are currently ignored.)  */)
   (Lisp_Object display, Lisp_Object xrm_string, Lisp_Object must_succeed)
 {
   unsigned char *xrm_option;
@@ -4179,6 +4170,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 +4207,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 +4220,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 +4321,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);
@@ -5007,7 +5003,7 @@
   int root_x, root_y;
   struct buffer *old_buffer;
   struct text_pos pos;
-  int i, width, height;
+  int i, width, height, seen_reversed_p;
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
   int old_windows_or_buffers_changed = windows_or_buffers_changed;
   int count = SPECPDL_INDEX ();
@@ -5148,7 +5144,7 @@
   try_window (FRAME_ROOT_WINDOW (f), pos, TRY_WINDOW_IGNORE_FONTS_CHANGE);
 
   /* Compute width and height of the tooltip.  */
-  width = height = 0;
+  width = height = seen_reversed_p = 0;
   for (i = 0; i < w->desired_matrix->nrows; ++i)
     {
       struct glyph_row *row = &w->desired_matrix->rows[i];
@@ -5163,19 +5159,74 @@
       row->full_width_p = 1;
 
       row_width = row->pixel_width;
-      /* There's a glyph at the end of rows that is used to place
-	 the cursor there.  Don't include the width of this glyph.  */
       if (row->used[TEXT_AREA])
 	{
-	  last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1];
-	  if (INTEGERP (last->object))
-	    row_width -= last->pixel_width;
+	  /* There's a glyph at the end of rows that is used to place
+	     the cursor there.  Don't include the width of this glyph.  */
+	  if (!row->reversed_p)
+	    {
+	      last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1];
+	      if (INTEGERP (last->object))
+		row_width -= last->pixel_width;
+	    }
+	  else
+	    {
+	      /* There could be a stretch glyph at the beginning of R2L
+		 rows that is produced by extend_face_to_end_of_line.
+		 Don't count that glyph.  */
+	      struct glyph *g = row->glyphs[TEXT_AREA];
+
+	      if (g->type == STRETCH_GLYPH && INTEGERP (g->object))
+		{
+		  row_width -= g->pixel_width;
+		  seen_reversed_p = 1;
+		}
+	    }
 	}
 
       height += row->height;
       width = max (width, row_width);
     }
 
+  /* If we've seen partial-length R2L rows, we need to re-adjust the
+     tool-tip frame width and redisplay it again, to avoid over-wide
+     tips due to the stretch glyph that extends R2L lines to full
+     width of the frame.  */
+  if (seen_reversed_p)
+    {
+      /* w->total_cols and FRAME_TOTAL_COLS want the width in columns,
+	 not in pixels.  */
+      width /= WINDOW_FRAME_COLUMN_WIDTH (w);
+      w->total_cols = make_number (width);
+      FRAME_TOTAL_COLS (f) = width;
+      adjust_glyphs (f);
+      clear_glyph_matrix (w->desired_matrix);
+      clear_glyph_matrix (w->current_matrix);
+      try_window (FRAME_ROOT_WINDOW (f), pos, 0);
+      width = height = 0;
+      /* Recompute width and height of the tooltip.  */
+      for (i = 0; i < w->desired_matrix->nrows; ++i)
+	{
+	  struct glyph_row *row = &w->desired_matrix->rows[i];
+	  struct glyph *last;
+	  int row_width;
+
+	  if (!row->enabled_p || !row->displays_text_p)
+	    break;
+	  row->full_width_p = 1;
+	  row_width = row->pixel_width;
+	  if (row->used[TEXT_AREA] && !row->reversed_p)
+	    {
+	      last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1];
+	      if (INTEGERP (last->object))
+		row_width -= last->pixel_width;
+	    }
+
+	  height += row->height;
+	  width = max (width, row_width);
+	}
+    }
+
   /* Add the frame's internal border to the width and height the X
      window should have.  */
   height += 2 * FRAME_INTERNAL_BORDER_WIDTH (f);
@@ -5299,9 +5350,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 +5364,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 +5391,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 +5564,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 +6072,3 @@
 
 #endif /* HAVE_X_WINDOWS */
 
-/* arch-tag: 55040d02-5485-4d58-8b22-95a7a05f3288
-   (do not change this comment) */
--- a/src/xftfont.c	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/xftfont.c	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/xmenu.c	Mon Nov 08 14:19:54 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"
@@ -2532,13 +2533,16 @@
 
 #endif /* HAVE_MENUS */
 
-/* Detect if a dialog or menu has been posted.  */
+#ifndef MSDOS
+/* Detect if a dialog or menu has been posted.  MSDOS has its own
+   implementation on msdos.c.  */
 
 int
 popup_activated (void)
 {
   return popup_activated_flag;
 }
+#endif	/* not MSDOS */
 
 /* The following is used by delayed window autoselection.  */
 
--- a/src/xrdb.c	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/xrdb.c	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/xterm.c	Mon Nov 08 14:19:54 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.
 
@@ -547,22 +548,22 @@
 x_update_window_begin (struct window *w)
 {
   struct frame *f = XFRAME (WINDOW_FRAME (w));
-  struct x_display_info *display_info = FRAME_X_DISPLAY_INFO (f);
+  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
 
   updated_window = w;
   set_output_cursor (&w->cursor);
 
   BLOCK_INPUT;
 
-  if (f == display_info->mouse_face_mouse_frame)
+  if (f == hlinfo->mouse_face_mouse_frame)
     {
       /* Don't do highlighting for mouse motion during the update.  */
-      display_info->mouse_face_defer = 1;
+      hlinfo->mouse_face_defer = 1;
 
       /* If F needs to be redrawn, simply forget about any prior mouse
 	 highlighting.  */
       if (FRAME_GARBAGED_P (f))
-	display_info->mouse_face_window = Qnil;
+	hlinfo->mouse_face_window = Qnil;
     }
 
   UNBLOCK_INPUT;
@@ -602,7 +603,7 @@
 static void
 x_update_window_end (struct window *w, int cursor_on_p, int mouse_face_overwritten_p)
 {
-  struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (XFRAME (w->frame));
+  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (XFRAME (w->frame));
 
   if (!w->pseudo_window_p)
     {
@@ -623,9 +624,9 @@
      XTframe_up_to_date to redisplay the mouse highlight.  */
   if (mouse_face_overwritten_p)
     {
-      dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1;
-      dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
-      dpyinfo->mouse_face_window = Qnil;
+      hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
+      hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
+      hlinfo->mouse_face_window = Qnil;
     }
 
   updated_window = NULL;
@@ -639,7 +640,7 @@
 x_update_end (struct frame *f)
 {
   /* Mouse highlight may be displayed again.  */
-  FRAME_X_DISPLAY_INFO (f)->mouse_face_defer = 0;
+  MOUSE_HL_INFO (f)->mouse_face_defer = 0;
 
 #ifndef XFlush
   BLOCK_INPUT;
@@ -658,17 +659,17 @@
 {
   if (FRAME_X_P (f))
     {
-      struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
-
-      if (dpyinfo->mouse_face_deferred_gc
-	  || f == dpyinfo->mouse_face_mouse_frame)
+      Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
+
+      if (hlinfo->mouse_face_deferred_gc
+	  || f == hlinfo->mouse_face_mouse_frame)
 	{
 	  BLOCK_INPUT;
-	  if (dpyinfo->mouse_face_mouse_frame)
-	    note_mouse_highlight (dpyinfo->mouse_face_mouse_frame,
-				  dpyinfo->mouse_face_mouse_x,
-				  dpyinfo->mouse_face_mouse_y);
-	  dpyinfo->mouse_face_deferred_gc = 0;
+	  if (hlinfo->mouse_face_mouse_frame)
+	    note_mouse_highlight (hlinfo->mouse_face_mouse_frame,
+				  hlinfo->mouse_face_mouse_x,
+				  hlinfo->mouse_face_mouse_y);
+	  hlinfo->mouse_face_deferred_gc = 0;
 	  UNBLOCK_INPUT;
 	}
     }
@@ -969,7 +970,7 @@
   struct face *face;
 
   /* What face has to be used last for the mouse face?  */
-  face_id = FRAME_X_DISPLAY_INFO (s->f)->mouse_face_face_id;
+  face_id = MOUSE_HL_INFO (s->f)->mouse_face_face_id;
   face = FACE_FROM_ID (s->f, face_id);
   if (face == NULL)
     face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
@@ -1329,6 +1330,83 @@
 }
 
 
+/* Draw the foreground of glyph string S for glyphless characters.  */
+
+static void
+x_draw_glyphless_glyph_string_foreground (struct glyph_string *s)
+{
+  struct glyph *glyph = s->first_glyph;
+  XChar2b char2b[8];
+  int x, i, j;
+
+  /* If first glyph of S has a left box line, start drawing the text
+     of S to the right of that box line.  */
+  if (s->face && s->face->box != FACE_NO_BOX
+      && s->first_glyph->left_box_line_p)
+    x = s->x + eabs (s->face->box_line_width);
+  else
+    x = s->x;
+
+  s->char2b = char2b;
+
+  for (i = 0; i < s->nchars; i++, glyph++)
+    {
+      char buf[7], *str = NULL;
+      int len = glyph->u.glyphless.len;
+
+      if (glyph->u.glyphless.method == GLYPHLESS_DISPLAY_ACRONYM)
+	{
+	  if (len > 0
+	      && CHAR_TABLE_P (Vglyphless_char_display)
+	      && (CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (Vglyphless_char_display))
+		  >= 1))
+	    {
+	      Lisp_Object acronym
+		= (! glyph->u.glyphless.for_no_font
+		   ? CHAR_TABLE_REF (Vglyphless_char_display,
+				     glyph->u.glyphless.ch)
+		   : XCHAR_TABLE (Vglyphless_char_display)->extras[0]);
+	      if (STRINGP (acronym))
+		str = (char *) SDATA (acronym);
+	    }
+	}
+      else if (glyph->u.glyphless.method == GLYPHLESS_DISPLAY_HEXA_CODE)
+	{
+	  sprintf ((char *) buf, "%0*X",
+		   glyph->u.glyphless.ch < 0x10000 ? 4 : 6,
+		   glyph->u.glyphless.ch);
+	  str = buf;
+	}
+
+      if (str)
+	{
+	  int upper_len = (len + 1) / 2;
+	  unsigned code;
+
+	  /* It is assured that all LEN characters in STR is ASCII.  */
+	  for (j = 0; j < len; j++)
+	    {
+	      code = s->font->driver->encode_char (s->font, str[j]);
+	      STORE_XCHAR2B (char2b + j, code >> 8, code & 0xFF);
+	    }
+	  s->font->driver->draw (s, 0, upper_len,
+				 x + glyph->slice.glyphless.upper_xoff,
+				 s->ybase + glyph->slice.glyphless.upper_yoff,
+				 0);
+	  s->font->driver->draw (s, upper_len, len,
+				 x + glyph->slice.glyphless.lower_xoff,
+				 s->ybase + glyph->slice.glyphless.lower_yoff,
+				 0);
+	}
+      if (glyph->u.glyphless.method != GLYPHLESS_DISPLAY_THIN_SPACE)
+	XDrawRectangle (s->display, s->window, s->gc,
+			x, s->ybase - glyph->ascent,
+			glyph->pixel_width - 1,
+			glyph->ascent + glyph->descent - 1);
+      x += glyph->pixel_width;
+   }
+}
+
 #ifdef USE_X_TOOLKIT
 
 static struct frame *x_frame_of_widget (Widget);
@@ -2655,6 +2733,14 @@
       x_draw_composite_glyph_string_foreground (s);
       break;
 
+    case GLYPHLESS_GLYPH:
+      if (s->for_overlaps)
+	s->background_filled_p = 1;
+      else
+	x_draw_glyph_string_background (s, 1);
+      x_draw_glyphless_glyph_string_foreground (s);
+      break;
+
     default:
       abort ();
     }
@@ -5702,6 +5788,7 @@
   struct frame *f = NULL;
   struct coding_system coding;
   XEvent event = *eventp;
+  Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight;
 
   *finish = X_EVENT_NORMAL;
 
@@ -6151,12 +6238,12 @@
 
       /* If mouse-highlight is an integer, input clears out
 	 mouse highlighting.  */
-      if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)
+      if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)
 	  && (f == 0
-	      || !EQ (f->tool_bar_window, dpyinfo->mouse_face_window)))
+	      || !EQ (f->tool_bar_window, hlinfo->mouse_face_window)))
         {
-          clear_mouse_face (dpyinfo);
-          dpyinfo->mouse_face_hidden = 1;
+          clear_mouse_face (hlinfo);
+          hlinfo->mouse_face_hidden = 1;
         }
 
 #if defined USE_MOTIF && defined USE_TOOLKIT_SCROLL_BARS
@@ -6513,12 +6600,12 @@
       f = x_top_window_to_frame (dpyinfo, event.xcrossing.window);
       if (f)
         {
-          if (f == dpyinfo->mouse_face_mouse_frame)
+          if (f == hlinfo->mouse_face_mouse_frame)
             {
               /* If we move outside the frame, then we're
                  certainly no longer on any text in the frame.  */
-              clear_mouse_face (dpyinfo);
-              dpyinfo->mouse_face_mouse_frame = 0;
+              clear_mouse_face (hlinfo);
+              hlinfo->mouse_face_mouse_frame = 0;
             }
 
           /* Generate a nil HELP_EVENT to cancel a help-echo.
@@ -6551,10 +6638,10 @@
         else
           f = x_window_to_frame (dpyinfo, event.xmotion.window);
 
-        if (dpyinfo->mouse_face_hidden)
+        if (hlinfo->mouse_face_hidden)
           {
-            dpyinfo->mouse_face_hidden = 0;
-            clear_mouse_face (dpyinfo);
+            hlinfo->mouse_face_hidden = 0;
+            clear_mouse_face (hlinfo);
           }
 
 #ifdef USE_GTK
@@ -6609,7 +6696,7 @@
 
             /* If we move outside the frame, then we're
                certainly no longer on any text in the frame.  */
-            clear_mouse_face (dpyinfo);
+            clear_mouse_face (hlinfo);
           }
 
         /* If the contents of the global variable help_echo_string
@@ -7669,44 +7756,43 @@
 	delete_frame (frame, Qnoelisp);
       }
 
-  /* We have to close the display to inform Xt that it doesn't
-     exist anymore.  If we don't, Xt will continue to wait for
-     events from the display.  As a consequence, a sequence of
-
-     M-x make-frame-on-display RET :1 RET
-     ...kill the new frame, so that we get an IO error...
-     M-x make-frame-on-display RET :1 RET
-
-     will indefinitely wait in Xt for events for display `:1', opened
-     in the first call to make-frame-on-display.
-
-     Closing the display is reported to lead to a bus error on
-     OpenWindows in certain situations.  I suspect that is a bug
-     in OpenWindows.  I don't know how to circumvent it here.  */
-
+  /* If DPYINFO is null, this means we didn't open the display in the
+     first place, so don't try to close it.  */
   if (dpyinfo)
     {
 #ifdef USE_X_TOOLKIT
-      /* If DPYINFO is null, this means we didn't open the display
-	 in the first place, so don't try to close it.  */
-      {
-	fatal_error_signal_hook = x_fatal_error_signal;
-	XtCloseDisplay (dpy);
-	fatal_error_signal_hook = NULL;
-      }
-#endif
+      /* We have to close the display to inform Xt that it doesn't
+	 exist anymore.  If we don't, Xt will continue to wait for
+	 events from the display.  As a consequence, a sequence of
+
+	 M-x make-frame-on-display RET :1 RET
+	 ...kill the new frame, so that we get an IO error...
+	 M-x make-frame-on-display RET :1 RET
+
+	 will indefinitely wait in Xt for events for display `:1',
+	 opened in the first call to make-frame-on-display.
+
+	 Closing the display is reported to lead to a bus error on
+	 OpenWindows in certain situations.  I suspect that is a bug
+	 in OpenWindows.  I don't know how to circumvent it here.  */
+      fatal_error_signal_hook = x_fatal_error_signal;
+      XtCloseDisplay (dpy);
+      fatal_error_signal_hook = NULL;
+#endif /* USE_X_TOOLKIT */
 
 #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);
-#endif
+      /* A long-standing GTK bug prevents proper disconnect handling
+	 (https://bugzilla.gnome.org/show_bug.cgi?id=85715).  Once,
+	 the resulting Glib error message loop filled a user's disk.
+	 To avoid this, kill Emacs unconditionally on disconnect.  */
+      shut_down_emacs (0, 0, Qnil);
+      fprintf (stderr, "%s\n\
+When compiled with GTK, Emacs cannot recover from X disconnects.\n\
+This is a GTK bug: https://bugzilla.gnome.org/show_bug.cgi?id=85715\n\
+For details, see etc/PROBLEMS.\n",
+	       error_msg);
+      abort ();
+#endif /* USE_GTK */
 
       /* Indicate that this display is dead.  */
       dpyinfo->display = 0;
@@ -9300,6 +9386,7 @@
   struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
   Lisp_Object bar;
   struct scroll_bar *b;
+  Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight;
 
   BLOCK_INPUT;
 
@@ -9393,15 +9480,15 @@
   if (f == dpyinfo->x_highlight_frame)
     dpyinfo->x_highlight_frame = 0;
 
-  if (f == dpyinfo->mouse_face_mouse_frame)
-    {
-      dpyinfo->mouse_face_beg_row
-	= dpyinfo->mouse_face_beg_col = -1;
-      dpyinfo->mouse_face_end_row
-	= dpyinfo->mouse_face_end_col = -1;
-      dpyinfo->mouse_face_window = Qnil;
-      dpyinfo->mouse_face_deferred_gc = 0;
-      dpyinfo->mouse_face_mouse_frame = 0;
+  if (f == hlinfo->mouse_face_mouse_frame)
+    {
+      hlinfo->mouse_face_beg_row
+	= hlinfo->mouse_face_beg_col = -1;
+      hlinfo->mouse_face_end_row
+	= hlinfo->mouse_face_end_col = -1;
+      hlinfo->mouse_face_window = Qnil;
+      hlinfo->mouse_face_deferred_gc = 0;
+      hlinfo->mouse_face_mouse_frame = 0;
     }
 
   UNBLOCK_INPUT;
@@ -9778,6 +9865,7 @@
   struct terminal *terminal;
   struct x_display_info *dpyinfo;
   XrmDatabase xrdb;
+  Mouse_HLInfo *hlinfo;
 
   BLOCK_INPUT;
 
@@ -9908,6 +9996,7 @@
 
   dpyinfo = (struct x_display_info *) xmalloc (sizeof (struct x_display_info));
   memset (dpyinfo, 0, sizeof *dpyinfo);
+  hlinfo = &dpyinfo->mouse_highlight;
 
   terminal = x_create_terminal (dpyinfo);
 
@@ -10030,16 +10119,16 @@
   dpyinfo->bitmaps_size = 0;
   dpyinfo->bitmaps_last = 0;
   dpyinfo->scratch_cursor_gc = 0;
-  dpyinfo->mouse_face_mouse_frame = 0;
-  dpyinfo->mouse_face_deferred_gc = 0;
-  dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1;
-  dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
-  dpyinfo->mouse_face_face_id = DEFAULT_FACE_ID;
-  dpyinfo->mouse_face_window = Qnil;
-  dpyinfo->mouse_face_overlay = Qnil;
-  dpyinfo->mouse_face_mouse_x = dpyinfo->mouse_face_mouse_y = 0;
-  dpyinfo->mouse_face_defer = 0;
-  dpyinfo->mouse_face_hidden = 0;
+  hlinfo->mouse_face_mouse_frame = 0;
+  hlinfo->mouse_face_deferred_gc = 0;
+  hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
+  hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
+  hlinfo->mouse_face_face_id = DEFAULT_FACE_ID;
+  hlinfo->mouse_face_window = Qnil;
+  hlinfo->mouse_face_overlay = Qnil;
+  hlinfo->mouse_face_mouse_x = hlinfo->mouse_face_mouse_y = 0;
+  hlinfo->mouse_face_defer = 0;
+  hlinfo->mouse_face_hidden = 0;
   dpyinfo->x_focus_frame = 0;
   dpyinfo->x_focus_event_frame = 0;
   dpyinfo->x_highlight_frame = 0;
@@ -10682,9 +10771,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 +10841,3 @@
 
 #endif /* HAVE_X_WINDOWS */
 
-/* arch-tag: 6d4e4cb7-abc1-4302-9585-d84dcfb09d0f
-   (do not change this comment) */
--- a/src/xterm.h	Mon Nov 08 14:19:24 2010 +0900
+++ b/src/xterm.h	Mon Nov 08 14:19:54 2010 +0900
@@ -190,36 +190,9 @@
   /* Reusable Graphics Context for drawing a cursor in a non-default face. */
   GC scratch_cursor_gc;
 
-  /* These variables describe the range of text currently shown in its
-     mouse-face, together with the window they apply to.  As long as
-     the mouse stays within this range, we need not redraw anything on
-     its account.  Rows and columns are glyph matrix positions in
-     MOUSE_FACE_WINDOW.  */
-  int mouse_face_beg_row, mouse_face_beg_col;
-  int mouse_face_beg_x, mouse_face_beg_y;
-  int mouse_face_end_row, mouse_face_end_col;
-  int mouse_face_end_x, mouse_face_end_y;
-  int mouse_face_past_end;
-  Lisp_Object mouse_face_window;
-  int mouse_face_face_id;
-  Lisp_Object mouse_face_overlay;
-
-  /* 1 if a mouse motion event came and we didn't handle it right away because
-     gc was in progress.  */
-  int mouse_face_deferred_gc;
-
-  /* FRAME and X, Y position of mouse when last checked for
-     highlighting.  X and Y can be negative or out of range for the frame.  */
-  struct frame *mouse_face_mouse_frame;
-  int mouse_face_mouse_x, mouse_face_mouse_y;
-
-  /* Nonzero means defer mouse-motion highlighting.  */
-  int mouse_face_defer;
-
-  /* Nonzero means that the mouse highlight should not be shown.  */
-  int mouse_face_hidden;
-
-  int mouse_face_image_state;
+  /* Information about the range of text currently shown in
+     mouse-face.  */
+  Mouse_HLInfo mouse_highlight;
 
   char *x_id_name;
 
--- a/test/ChangeLog	Mon Nov 08 14:19:24 2010 +0900
+++ b/test/ChangeLog	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/test/comint-testsuite.el	Mon Nov 08 14:19:54 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	Mon Nov 08 14:19:24 2010 +0900
+++ b/test/indent/octave.m	Mon Nov 08 14:19:54 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