changeset 91056:1251cabc40b7

Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 890-898) - Update from CVS - Merge from emacs--rel--22 * emacs--rel--22 (patch 122-128) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 257-258) - Merge from emacs--rel--22 - Update from CVS Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-270
author Miles Bader <miles@gnu.org>
date Fri, 19 Oct 2007 00:00:21 +0000
parents 46bc3a01b2fa (current diff) ad84adc0e027 (diff)
children 5e056bb0109f
files ChangeLog FTP admin/ChangeLog admin/make-emacs admin/nt/makedist.bat configure configure.in etc/NEWS etc/NEWS.22 etc/PROBLEMS lisp/ChangeLog lisp/bindings.el lisp/bs.el lisp/dired.el lisp/emacs-lisp/advice.el lisp/emacs-lisp/find-func.el lisp/emerge.el lisp/eshell/esh-cmd.el lisp/faces.el lisp/files.el lisp/filesets.el lisp/gnus/ChangeLog lisp/gnus/gnus-sum.el lisp/gnus/gnus-util.el lisp/gnus/gnus-win.el lisp/help-fns.el lisp/ibuf-ext.el lisp/indent.el lisp/international/encoded-kb.el lisp/loadhist.el lisp/mail/sendmail.el lisp/net/tramp.el lisp/progmodes/cc-menus.el lisp/progmodes/compile.el lisp/progmodes/delphi.el lisp/server.el lisp/simple.el lisp/term/xterm.el lisp/textmodes/artist.el lisp/textmodes/fill.el lisp/textmodes/ispell.el lisp/textmodes/org.el lisp/time.el lisp/vc-hooks.el lisp/vc.el lisp/xt-mouse.el nt/ChangeLog nt/makefile.w32-in src/ChangeLog src/alloc.c src/buffer.c src/coding.c src/config.in src/data.c src/dired.c src/doc.c src/eval.c src/fileio.c src/fns.c src/frame.c src/keyboard.c src/keymap.c src/lisp.h src/lread.c src/macfns.c src/macterm.c src/minibuf.c src/print.c src/process.c src/textprop.c src/w32fns.c src/w32menu.c src/window.c src/xdisp.c src/xfns.c src/xselect.c
diffstat 92 files changed, 1851 insertions(+), 1020 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Oct 15 15:43:53 2007 +0000
+++ b/ChangeLog	Fri Oct 19 00:00:21 2007 +0000
@@ -1,3 +1,12 @@
+2007-10-17  Chong Yidong  <cyd@stupidchicken.com>
+
+	* configure.in (HAVE_RES_INIT): Define if res_init() exists.
+	(HAVE_LIBRESOLV): Also define if we are using res_init().
+
+2007-10-17  Glenn Morris  <rgm@gnu.org>
+
+	* FTP: Remove file, since it's just a duplicate of one in etc/.
+
 2007-10-05  Eli Zaretskii  <eliz@gnu.org>
 
 	* config.bat: Fix configuring `doc' due to changes in the
--- a/FTP	Mon Oct 15 15:43:53 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-For information about how to obtain GNU Emacs and other GNU software
-by FTP, please see <http://www.gnu.org/order/ftp.html>.
-
-Information about Emacs is also available at
-<http://www.gnu.org/software/emacs/>.
-
--- a/admin/ChangeLog	Mon Oct 15 15:43:53 2007 +0000
+++ b/admin/ChangeLog	Fri Oct 19 00:00:21 2007 +0000
@@ -1,3 +1,7 @@
+2007-10-17  Juanma Barranquero  <lekktu@gmail.com>
+
+	* make-emacs: Doc fix.
+
 2007-08-28  Glenn Morris  <rgm@gnu.org>
 
 	* admin.el: Provide self.
@@ -167,7 +171,7 @@
 2005-10-17  Bill Wohler  <wohler@newt.com>
 
 	* FOR-RELEASE (DOCUMENTATION): Removed lisp/toolbar from list
-	since it's gone. Also marked mh-e as done.
+	since it's gone.  Also marked mh-e as done.
 
 2005-10-11  Juanma Barranquero  <lekktu@gmail.com>
 
@@ -213,11 +217,11 @@
 
 2005-03-30  Marcelo Toledo  <marcelo@marcelotoledo.org>
 
-	* FOR-RELEASE (Documentation): Added check the Emacs Tutorial. The
-        first line of every tutorial must begin with a sentence saying
-        "Emacs Tutorial" in the respective language.  This should be
-        followed by "See end for copying conditions", likewise in the
-        respective language.
+	* FOR-RELEASE (Documentation): Added check the Emacs Tutorial.
+	The first line of every tutorial must begin with a sentence saying
+	"Emacs Tutorial" in the respective language.  This should be
+	followed by "See end for copying conditions", likewise in the
+	respective language.
 
 2005-03-29  Luc Teirlinck  <teirllm@auburn.edu>
 
--- a/admin/make-emacs	Mon Oct 15 15:43:53 2007 +0000
+++ b/admin/make-emacs	Fri Oct 19 00:00:21 2007 +0000
@@ -68,7 +68,7 @@
  --help			show this help
  --all			make clean versionclean first
  --boot			make boostrap, log to boot.log
- --enable-checking	ENABLE_CHECKING=1 (implies Lisp union type)
+ --enable-checking	ENABLE_CHECKING=1
  --no-warn		disable warnings
  --check-marked		GC_CHECK_MARKED_OBJECTS=1
  --optim		no debug defines
--- a/admin/nt/makedist.bat	Mon Oct 15 15:43:53 2007 +0000
+++ b/admin/nt/makedist.bat	Fri Oct 19 00:00:21 2007 +0000
@@ -35,8 +35,8 @@
 rem Info-ZIP zip seems to be broken on Windows.
 rem It always writes to zip.zip and treats the zipfile argument as one
 rem of the files to go in it.
-rem zip -9 -r %2-bin-i386 emacs-%1/BUGS emacs-%1/README emacs-%1/README.W32 emacs-%1/INSTALL emacs-%1/bin emacs-%1/etc emacs-%1/info emacs-%1/lisp emacs-%1/leim -x emacs.mdp *.pdb *.opt *~ CVS
-7z a -tZIP -mx=9 -xr!emacs.mdp -xr!*.pdb -xr!*.opt -xr!*~ -xr!CVS -xr!.arch-inventory %2-bin-i386.zip emacs-%1/BUGS emacs-%1/README emacs-%1/README.W32 emacs-%1/INSTALL emacs-%1/bin emacs-%1/etc emacs-%1/info emacs-%1/lisp emacs-%1/leim emacs-%1/site-lisp
+rem zip -9 -r %2-bin-i386 emacs-%1/BUGS emacs-%1/COPYING emacs-%1/README emacs-%1/README.W32 emacs-%1/INSTALL emacs-%1/bin emacs-%1/etc emacs-%1/info emacs-%1/lisp emacs-%1/leim -x emacs.mdp *.pdb *.opt *~ CVS
+7z a -tZIP -mx=9 -xr!emacs.mdp -xr!*.pdb -xr!*.opt -xr!*~ -xr!CVS -xr!.arch-inventory %2-bin-i386.zip emacs-%1/BUGS emacs-%1/COPYING emacs-%1/README emacs-%1/README.W32 emacs-%1/INSTALL emacs-%1/bin emacs-%1/etc emacs-%1/info emacs-%1/lisp emacs-%1/leim emacs-%1/site-lisp
 del emacs-%1\README.W32
 if not (%4) == () goto end
 
@@ -49,8 +49,8 @@
 rem Info-ZIP zip seems to be broken on Windows.
 rem It always writes to zip.zip and treats the zipfile argument as one
 rem of the files to go in it.
-rem zip -9 -r %2-barebin-i386.zip emacs-%1/README.W32 emacs-%1/bin emacs-%1/etc/DOC-X
-7z a -tZIP -mx=9 %2-barebin-i386.zip emacs-%1/README.W32 emacs-%1/bin emacs-%1/etc/DOC-X
+rem zip -9 -r %2-barebin-i386.zip emacs-%1/README.W32 emacs-%1/bin emacs-%1/etc/DOC-X emacs-%1/COPYING
+7z a -tZIP -mx=9 %2-barebin-i386.zip emacs-%1/README.W32 emacs-%1/bin emacs-%1/etc/DOC-X emacs-%1/COPYING
 del emacs-%1\README.W32
 if not (%4) == () goto end
 
--- a/configure	Mon Oct 15 15:43:53 2007 +0000
+++ b/configure	Fri Oct 19 00:00:21 2007 +0000
@@ -16312,10 +16312,9 @@
 
 
 
-
 for ac_func in gethostname getdomainname dup2 \
 rename closedir mkdir rmdir sysinfo getrusage get_current_dir_name \
-random lrand48 bcopy bcmp logb frexp fmod rint cbrt ftime res_init setsid \
+random lrand48 bcopy bcmp logb frexp fmod rint cbrt ftime setsid \
 strerror fpathconf select mktime euidaccess getpagesize tzset setlocale \
 utimes setrlimit setpgid getcwd getwd shutdown getaddrinfo \
 __fpending mblen mbrlen mbsinit strsignal setitimer ualarm index rindex \
@@ -18922,13 +18921,11 @@
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include <sys/types.h> /* for off_t */
-     #include <stdio.h>
-int
-main ()
-{
-int (*fp) (FILE *, off_t, int) = fseeko;
-     return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);
+#include <stdio.h>
+int
+main ()
+{
+return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0);
   ;
   return 0;
 }
@@ -18968,13 +18965,11 @@
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 #define _LARGEFILE_SOURCE 1
-#include <sys/types.h> /* for off_t */
-     #include <stdio.h>
-int
-main ()
-{
-int (*fp) (FILE *, off_t, int) = fseeko;
-     return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);
+#include <stdio.h>
+int
+main ()
+{
+return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0);
   ;
   return 0;
 }
@@ -20003,10 +19998,165 @@
 fi
 
 
+# Do we have res_init, for detecting changes in /etc/resolv.conf?
+
+resolv=no
+{ echo "$as_me:$LINENO: checking for res_init" >&5
+echo $ECHO_N "checking for res_init... $ECHO_C" >&6; }
+if test "${ac_cv_func_res_init+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define res_init to an innocuous variant, in case <limits.h> declares res_init.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define res_init innocuous_res_init
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char res_init (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef res_init
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char res_init ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_res_init || defined __stub___res_init
+choke me
+#endif
+
+int
+main ()
+{
+return res_init ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_func_res_init=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_func_res_init=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_func_res_init" >&5
+echo "${ECHO_T}$ac_cv_func_res_init" >&6; }
+if test $ac_cv_func_res_init = yes; then
+  have_res_init=yes
+else
+  have_res_init=no
+fi
+
+if test "$have_res_init" = no; then
+  OLIBS="$LIBS"
+  LIBS="$LIBS -lresolv"
+  { echo "$as_me:$LINENO: checking for res_init with -lresolv" >&5
+echo $ECHO_N "checking for res_init with -lresolv... $ECHO_C" >&6; }
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <netinet/in.h>
+#include <arpa/nameser.h>
+#include <resolv.h>
+int
+main ()
+{
+res_init();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  have_res_init=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	have_res_init=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+  { echo "$as_me:$LINENO: result: $have_res_init" >&5
+echo "${ECHO_T}$have_res_init" >&6; }
+  if test "$have_res_init" = yes ; then
+    resolv=yes
+  fi
+  LIBS="$OLIBS"
+fi
+
+if test "$have_res_init" = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_RES_INIT 1
+_ACEOF
+
+fi
+
 # Do we need the Hesiod library to provide the support routines?
 if test "$with_hesiod" = yes ; then
   # Don't set $LIBS here -- see comments above.
-  resolv=no
   { echo "$as_me:$LINENO: checking for res_send" >&5
 echo $ECHO_N "checking for res_send... $ECHO_C" >&6; }
 if test "${ac_cv_func_res_send+set}" = set; then
@@ -20312,11 +20462,6 @@
 
   if test "$resolv" = yes ; then
     RESOLVLIB=-lresolv
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_LIBRESOLV 1
-_ACEOF
-
   else
     RESOLVLIB=
   fi
@@ -20479,6 +20624,15 @@
 
 fi
 
+# Do we need libresolv (due to res_init or Hesiod)?
+if test "$resolv" = yes ; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_LIBRESOLV 1
+_ACEOF
+
+fi
+
 # These tell us which Kerberos-related libraries to use.
 if test "${with_kerberos+set}" = set; then
 
--- a/configure.in	Mon Oct 15 15:43:53 2007 +0000
+++ b/configure.in	Fri Oct 19 00:00:21 2007 +0000
@@ -2794,7 +2794,7 @@
 
 AC_CHECK_FUNCS(gethostname getdomainname dup2 \
 rename closedir mkdir rmdir sysinfo getrusage get_current_dir_name \
-random lrand48 bcopy bcmp logb frexp fmod rint cbrt ftime res_init setsid \
+random lrand48 bcopy bcmp logb frexp fmod rint cbrt ftime setsid \
 strerror fpathconf select mktime euidaccess getpagesize tzset setlocale \
 utimes setrlimit setpgid getcwd getwd shutdown getaddrinfo \
 __fpending mblen mbrlen mbsinit strsignal setitimer ualarm index rindex \
@@ -2838,17 +2838,38 @@
 # than to expect to find it in ncurses.
 AC_CHECK_LIB(ncurses, tparm)
 
+# Do we have res_init, for detecting changes in /etc/resolv.conf?
+
+resolv=no
+AC_CHECK_FUNC(res_init, have_res_init=yes, have_res_init=no)
+if test "$have_res_init" = no; then
+  OLIBS="$LIBS"
+  LIBS="$LIBS -lresolv"
+  AC_MSG_CHECKING(for res_init with -lresolv)
+  AC_TRY_LINK([#include <netinet/in.h>
+#include <arpa/nameser.h>
+#include <resolv.h> ],
+    [res_init();],
+    have_res_init=yes, have_res_init=no)
+  AC_MSG_RESULT($have_res_init)
+  if test "$have_res_init" = yes ; then
+    resolv=yes
+  fi
+  LIBS="$OLIBS"
+fi
+
+if test "$have_res_init" = yes; then
+  AC_DEFINE(HAVE_RES_INIT, 1, [Define to 1 if res_init is available.])
+fi
+
 # Do we need the Hesiod library to provide the support routines?
 if test "$with_hesiod" = yes ; then
   # Don't set $LIBS here -- see comments above.
-  resolv=no
   AC_CHECK_FUNC(res_send, , [AC_CHECK_FUNC(__res_send, ,
      [AC_CHECK_LIB(resolv, res_send, resolv=yes,
 		  [AC_CHECK_LIB(resolv, __res_send, resolv=yes)])])])
   if test "$resolv" = yes ; then
     RESOLVLIB=-lresolv
-    AC_DEFINE(HAVE_LIBRESOLV, 1,
-	      [Define to 1 if you have the resolv library (-lresolv).])
   else
     RESOLVLIB=
   fi
@@ -2858,6 +2879,12 @@
 	:, $RESOLVLIB)])
 fi
 
+# Do we need libresolv (due to res_init or Hesiod)?
+if test "$resolv" = yes ; then
+  AC_DEFINE(HAVE_LIBRESOLV, 1,
+            [Define to 1 if you have the resolv library (-lresolv).])
+fi
+
 # These tell us which Kerberos-related libraries to use.
 if test "${with_kerberos+set}" = set; then
   AC_CHECK_LIB(com_err, com_err)
--- a/doc/emacs/ChangeLog	Mon Oct 15 15:43:53 2007 +0000
+++ b/doc/emacs/ChangeLog	Fri Oct 19 00:00:21 2007 +0000
@@ -1,3 +1,38 @@
+2007-10-18  Martin Rudalics  <rudalics@gmx.at>
+
+	* trouble.texi (Quitting): Fix typo.
+
+2007-10-18  Glenn Morris  <rgm@gnu.org>
+
+	* frames.texi (Mode Line Mouse): Mention minor mode names.
+
+2007-10-17  Juri Linkov  <juri@jurta.org>
+
+	* text.texi (Fill Commands): Undocument fill-paragraph-or-region.
+	fill-paragraph operates on the active region in Transient Mark mode.
+	(Fill Prefix, Format Indentation): Replace fill-paragraph-or-region
+	with fill-paragraph.
+
+	* basic.texi (Arguments): Replace fill-paragraph-or-region with
+	fill-paragraph.
+
+	* fixit.texi (Spelling): ispell-word operates on the active region
+	in Transient Mark mode.
+
+2007-10-17  Aaron S. Hawley  <aaronh@garden.org>
+
+	* building.texi (Source Buffers):
+	* custom.texi (Init Non-ASCII):
+	* glossary.texi (Glossary): Use "key binding" consistently.
+
+2007-10-17  Juanma Barranquero  <lekktu@gmail.com>
+
+	* calendar.texi (Diary): Fix directive.
+
+2007-10-16  Richard Stallman  <rms@gnu.org>
+
+	* calendar.texi (Diary): Clarify text about diary file example.
+
 2007-10-13  Eric S. Raymond  <esr@snark.thyrsus.com>
 
 	* files.texi: Capitalize node names according to convention.
@@ -10,7 +45,7 @@
 
 	* emacs.texi:
 	* files.texi (Version Systems): Minor fixes to version-control material
-	suggseted by RMS and Robert J. Chassell.
+	suggested by RMS and Robert J. Chassell.
 
 2007-10-10  Eric S. Raymond  <esr@snark.thyrsus.com>
 
@@ -18,9 +53,9 @@
 	* vc-xtra.texi:
 	* vc1-xtra.texi:
 	* vc2-xtra.texi: Merge in changes for new VC with fileset-oriented
-	operations.  Change of terminology from 'version' to `revision'.
+	operations.  Change of terminology from `version' to `revision'.
 	Revise text for adequate description of VCSes with monotonic IDs.
-	* emacs.texi: Change of terminology from 'version' to `revision'.
+	* emacs.texi: Change of terminology from `version' to `revision'.
 
 2007-10-09  Eric S. Raymond  <esr@snark.thyrsus.com>
 
@@ -53,7 +88,7 @@
 2007-10-06  Eric S. Raymond  <esr@snark.thyrsus.com>
 
 	* files.texi: Update the section on version control for 2007
-	conditions. None of these changes are new-VC-specific; that
+	conditions.  None of these changes are new-VC-specific; that
 	will come later.
 
 2007-09-15  Glenn Morris  <rgm@gnu.org>
@@ -173,7 +208,7 @@
 
 2007-06-24  Karl Berry  <karl@gnu.org>
 
-	* emacs.texi: new Back-Cover Text.
+	* emacs.texi: New Back-Cover Text.
 
 2007-06-07  Alan Mackenzie  <acm@muc.de>
 
--- a/doc/emacs/basic.texi	Mon Oct 15 15:43:53 2007 +0000
+++ b/doc/emacs/basic.texi	Fri Oct 19 00:00:21 2007 +0000
@@ -707,7 +707,7 @@
 ``a lot'' of blank lines), and @kbd{C-u C-k} (kill four lines).
 
   Some commands care whether there is an argument, but ignore its
-value.  For example, the command @kbd{M-q} (@code{fill-paragraph-or-region})
+value.  For example, the command @kbd{M-q} (@code{fill-paragraph})
 fills text; with an argument, it justifies the text as well.
 (@xref{Filling}, for more information on @kbd{M-q}.)  Plain @kbd{C-u}
 is a handy way of providing an argument for such commands.
--- a/doc/emacs/building.texi	Mon Oct 15 15:43:53 2007 +0000
+++ b/doc/emacs/building.texi	Fri Oct 19 00:00:21 2007 +0000
@@ -911,7 +911,7 @@
 
 @c @findex gdb-mouse-set-clear-breakpoint
 @c @findex gdb-mouse-toggle-breakpoint
-Many GDB commands can be entered using keybindings or the tool bar but
+Many GDB commands can be entered using key bindings or the tool bar but
 sometimes it is quicker to use the fringe.  These commands either
 manipulate breakpoints or control program execution.  When there is no
 fringe, you can use the margin but this is only present when the
--- a/doc/emacs/calendar.texi	Mon Oct 15 15:43:53 2007 +0000
+++ b/doc/emacs/calendar.texi	Fri Oct 19 00:00:21 2007 +0000
@@ -989,9 +989,8 @@
 date.
 
   The name of the diary file is specified by the variable
-@code{diary-file}; @file{~/diary} is the default.  A sample diary file
-is (note that the file format is essentially the same as that used by
-the external shell utility @samp{calendar}):
+@code{diary-file}; @file{~/diary} is the default.  Here's an example
+showing what that file looks like:
 
 @example
 12/22/1988  Twentieth wedding anniversary!!
@@ -1008,8 +1007,10 @@
 @end example
 
 @noindent
-This example uses extra spaces to align the event descriptions of most
-of the entries.  Such formatting is purely a matter of taste.
+This format is essentially the same as the one used by the system's
+@command{calendar} utility.  This example uses extra spaces to align
+the event descriptions of most of the entries.  Such formatting is
+purely a matter of taste.
 
   Although you probably will start by creating a diary manually, Emacs
 provides a number of commands to let you view, add, and change diary
--- a/doc/emacs/custom.texi	Mon Oct 15 15:43:53 2007 +0000
+++ b/doc/emacs/custom.texi	Fri Oct 19 00:00:21 2007 +0000
@@ -2505,7 +2505,7 @@
 
   @strong{Warning:} if you change the keyboard encoding, or change
 between multibyte and unibyte mode, or anything that would alter which
-code @kbd{C-q} would insert for that character, this keybinding may
+code @kbd{C-q} would insert for that character, this key binding may
 stop working.  It is therefore advisable to use one and only one
 coding system, for your init file as well as the files you edit.  For
 example, don't mix the @samp{latin-1} and @samp{latin-9} coding
--- a/doc/emacs/fixit.texi	Mon Oct 15 15:43:53 2007 +0000
+++ b/doc/emacs/fixit.texi	Fri Oct 19 00:00:21 2007 +0000
@@ -325,7 +325,9 @@
   To check the spelling of the word around or before point, and
 optionally correct it as well, use the command @kbd{M-$}
 (@code{ispell-word}).  If the word is not correct, the command offers
-you various alternatives for what to do about it.
+you various alternatives for what to do about it.  When the mark is
+active in Transient Mark mode, this command operates on the active
+region like @code{ispell-region}.
 
 @findex ispell-buffer
 @findex ispell-region
--- a/doc/emacs/frames.texi	Mon Oct 15 15:43:53 2007 +0000
+++ b/doc/emacs/frames.texi	Fri Oct 19 00:00:21 2007 +0000
@@ -430,8 +430,8 @@
   You can use mouse clicks on window mode lines to select and manipulate
 windows.
 
-  Some areas of the mode line, such as the buffer name and the major
-mode name, have their own special mouse bindings.  These areas are
+  Some areas of the mode line, such as the buffer name, and major and minor
+mode names, have their own special mouse bindings.  These areas are
 highlighted when you hold the mouse over them, and information about
 the special bindings will be displayed (@pxref{Tooltips}).  This
 section's commands do not apply in those areas.
--- a/doc/emacs/glossary.texi	Mon Oct 15 15:43:53 2007 +0000
+++ b/doc/emacs/glossary.texi	Fri Oct 19 00:00:21 2007 +0000
@@ -658,7 +658,7 @@
 them extend exactly to a specified width.
 @xref{Format Justification}.
 
-@item Keybinding
+@item Key Binding
 See `binding.'
 
 @item Keyboard Macro
--- a/doc/emacs/text.texi	Mon Oct 15 15:43:53 2007 +0000
+++ b/doc/emacs/text.texi	Fri Oct 19 00:00:21 2007 +0000
@@ -486,11 +486,9 @@
 
 @table @kbd
 @item M-q
-Fill current paragraph or active region (@code{fill-paragraph-or-region}).
+Fill current paragraph (@code{fill-paragraph}).
 @item C-x f
 Set the fill column (@code{set-fill-column}).
-@item M-x fill-paragraph
-Fill current paragraph (@code{fill-paragraph}).
 @item M-x fill-region
 Fill each paragraph in the region (@code{fill-region}).
 @item M-x fill-region-as-paragraph
@@ -499,39 +497,35 @@
 Center a line.
 @end table
 
+@kindex M-q
 @findex fill-paragraph
-  To refill a paragraph, use @kbd{M-x fill-paragraph}.  This operates
-on the paragraph that point is inside, or the one after point if point
-is between paragraphs.  Refilling works by removing all the
-line-breaks, then inserting new ones where necessary.
+  To refill a paragraph, use the command @kbd{M-q}
+(@code{fill-paragraph}).  This operates on the paragraph that point is
+inside, or the one after point if point is between paragraphs.
+Refilling works by removing all the line-breaks, then inserting new ones
+where necessary.  When the mark is active in Transient Mark mode, this
+command operates on the active region like @code{fill-region}.
 
 @findex fill-region
   To refill many paragraphs, use @kbd{M-x fill-region}, which
 finds the paragraphs in the region and fills each of them.
 
-@kindex M-q
-@findex fill-paragraph-or-region
-  The command @kbd{M-q} (@code{fill-paragraph-or-region}), operates on
-the active region like @code{fill-region} when the mark is active in
-Transient Mark mode.  Otherwise, it operates on the current paragraph
-like @code{fill-paragraph}.
-
 @findex fill-region-as-paragraph
-  @kbd{M-q}, @code{fill-paragraph} and @code{fill-region} use the same
-criteria as @kbd{M-h} for finding paragraph boundaries (@pxref{Paragraphs}).
-For more control, you can use @kbd{M-x fill-region-as-paragraph},
-which refills everything between point and mark as a single paragraph.
-This command deletes any blank lines within the region, so separate
-blocks of text end up combined into one block.
+  @kbd{M-q} and @code{fill-region} use the same criteria as @kbd{M-h}
+for finding paragraph boundaries (@pxref{Paragraphs}).  For more
+control, you can use @kbd{M-x fill-region-as-paragraph}, which refills
+everything between point and mark as a single paragraph.  This command
+deletes any blank lines within the region, so separate blocks of text
+end up combined into one block.
 
 @cindex justification
   A numeric argument to @kbd{M-q} tells it to @dfn{justify} the text
 as well as filling it.  This means that extra spaces are inserted to
 make the right margin line up exactly at the fill column.  To remove
 the extra spaces, use @kbd{M-q} with no argument.  (Likewise for
-@code{fill-paragraph} and @code{fill-region}.)  Another way to control
-justification, and choose other styles of filling, is with the
-@code{justification} text property; see @ref{Format Justification}.
+@code{fill-region}.)  Another way to control justification, and choose
+other styles of filling, is with the @code{justification} text
+property; see @ref{Format Justification}.
 
 @kindex M-s @r{(Text mode)}
 @cindex centering
@@ -595,7 +589,7 @@
 @item C-x .
 Set the fill prefix (@code{set-fill-prefix}).
 @item M-q
-Fill a paragraph using current fill prefix (@code{fill-paragraph-or-region}).
+Fill a paragraph using current fill prefix (@code{fill-paragraph}).
 @item M-x fill-individual-paragraphs
 Fill the region, considering each change of indentation as starting a
 new paragraph.
@@ -2256,7 +2250,7 @@
 
   Sometimes, as a result of editing, the filling of a paragraph becomes
 messed up---parts of the paragraph may extend past the left or right
-margins.  When this happens, use @kbd{M-q} (@code{fill-paragraph-or-region}) to
+margins.  When this happens, use @kbd{M-q} (@code{fill-paragraph}) to
 refill the paragraph.
 
   The fill prefix, if any, works in addition to the specified paragraph
--- a/doc/emacs/trouble.texi	Mon Oct 15 15:43:53 2007 +0000
+++ b/doc/emacs/trouble.texi	Fri Oct 19 00:00:21 2007 +0000
@@ -84,7 +84,7 @@
 impossible unless special pains are taken for the particular system
 call within Emacs where the waiting occurs.  We have done this for the
 system calls that users are likely to want to quit from, but it's
-possible you will a case not handled.  In one very common
+possible you will encounter a case not handled.  In one very common
 case---waiting for file input or output using NFS---Emacs itself knows
 how to quit, but many NFS implementations simply do not allow user
 programs to stop waiting for NFS when the NFS server is hung.
--- a/doc/lispref/ChangeLog	Mon Oct 15 15:43:53 2007 +0000
+++ b/doc/lispref/ChangeLog	Fri Oct 19 00:00:21 2007 +0000
@@ -1,3 +1,9 @@
+2007-10-17  Juri Linkov  <juri@jurta.org>
+
+	* text.texi (Filling): Update arguments of fill-paragraph.
+	fill-paragraph operates on the active region in Transient Mark mode.
+	Remove fill-paragraph-or-region.
+
 2007-10-13  Karl Berry  <karl@gnu.org>
 
 	* elisp.texi (@dircategory): Move to after @copying,
--- a/doc/lispref/text.texi	Mon Oct 15 15:43:53 2007 +0000
+++ b/doc/lispref/text.texi	Fri Oct 19 00:00:21 2007 +0000
@@ -1432,11 +1432,14 @@
   When you call the filling functions interactively, using a prefix
 argument implies the value @code{full} for @var{justify}.
 
-@deffn Command fill-paragraph justify
+@deffn Command fill-paragraph &optional justify region
 This command fills the paragraph at or after point.  If
 @var{justify} is non-@code{nil}, each line is justified as well.
 It uses the ordinary paragraph motion commands to find paragraph
 boundaries.  @xref{Paragraphs,,, emacs, The GNU Emacs Manual}.
+Interactively, when @var{region} is non-@code{nil} in Transient Mark
+mode and the mark is active, this command calls @code{fill-region}
+on the active region.
 @end deffn
 
 @deffn Command fill-region start end &optional justify nosqueeze to-eop
@@ -1453,12 +1456,6 @@
 paragraphs.  @xref{Standard Regexps}.
 @end deffn
 
-@deffn Command fill-paragraph-or-region justify
-In Transient Mark mode, when the mark is active, this command calls
-@code{fill-region} on the active region.  Otherwise, it calls
-@code{fill-paragraph}.
-@end deffn
-
 @deffn Command fill-individual-paragraphs start end &optional justify citation-regexp
 This command fills each paragraph in the region according to its
 individual fill prefix.  Thus, if the lines of a paragraph were indented
--- a/etc/NEWS	Mon Oct 15 15:43:53 2007 +0000
+++ b/etc/NEWS	Fri Oct 19 00:00:21 2007 +0000
@@ -83,6 +83,9 @@
 ** The mode-line displays a `@' if the default-directory for the current buffer
 is on a remote machine, or a hyphen otherwise.
 
+** The mode-line displays a mode menu when mouse-1 is clicked on a minor mode,
+in the same way as it already did for major modes.
+
 ** The new command balance-windows-area balances windows both vertically
 and horizontally.
 
@@ -118,8 +121,9 @@
 +++
 ** M-q now fills the region if the region is active and
 `transient-mark-mode' is turned on.  Otherwise, it fills the current
-paragraph.  The new command bound to M-q is `fill-paragraph-or-region'.
+paragraph.
 
++++
 ** M-$ now checks spelling of the region if the region is active and
 `transient-mark-mode' is turned on.  Otherwise, it checks spelling of the
 word at point.
@@ -132,6 +136,10 @@
 
 ** New command kill-matching-buffers kills buffers whose name matches a regexp.
 
+** `interprogram-paste-function' can now return one string or a list
+of strings.  In the latter case, Emacs puts the second and following
+strings on the kill ring.
+
 ** Minibuffer changes:
 
 *** isearch started in the minibuffer searches in the minibuffer history.
--- a/etc/NEWS.22	Mon Oct 15 15:43:53 2007 +0000
+++ b/etc/NEWS.22	Fri Oct 19 00:00:21 2007 +0000
@@ -324,7 +324,7 @@
 keymaps that are active in the minibuffer are described below under
 "New keymaps for typing file names".
 
-If you want the old behavior back, put these two key bindings to your
+If you want the old behavior back, add these two key bindings to your
 ~/.emacs init file:
 
   (define-key minibuffer-local-filename-completion-map
--- a/etc/PROBLEMS	Mon Oct 15 15:43:53 2007 +0000
+++ b/etc/PROBLEMS	Fri Oct 19 00:00:21 2007 +0000
@@ -2204,6 +2204,13 @@
 of Windows. This is caused by a deficiency in the underlying system
 library function.
 
+The functions set-time-zone-rule, and display-time-world (which uses it)
+do not work on Windows. Fixing this is difficult, since Windows uses
+localtime for the system clock, and any attempt to change the timezone
+would have to be accompanied by a clock change for the results to remain
+consistent. The way in which these functions are used is not intended to
+cause such system-wide disruption.
+
 Files larger than 4GB cause overflow in the size (represented as a
 32-bit integer) reported by `file-attributes'.  This affects Dired as
 well, since the Windows port uses a Lisp emulation of `ls' that relies
--- a/lisp/ChangeLog	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/ChangeLog	Fri Oct 19 00:00:21 2007 +0000
@@ -1,3 +1,269 @@
+2007-10-18  Johan Bockg,Ae(Brd  <bojohan@gnu.org>
+
+	* net/tramp.el (tramp-rfn-eshadow-update-overlay): Save excursion.
+	Use `save-restriction' rather than `widen'.
+
+2007-10-18  Richard Stallman  <rms@gnu.org>
+
+	* time.el (display-time-world-time-format): Display day # not month #.
+
+2007-10-18  Reiner Steib  <Reiner.Steib@gmx.de>
+
+	* files.el (auto-mode-alist): Don't use doc-view for PS and EPS.
+
+	* doc-view.el: Remove version keyword.
+	(doc-view-ghostscript-program, doc-view-dvipdfm-program)
+	(doc-view-ps2pdf-program): Use executable-find.  Simplify custom type.
+	(doc-view-ghostscript-options): Improve custom type.
+	(doc-view-cache-directory, doc-view-conversion-buffer)
+	(doc-view-conversion-refresh-interval): Simplify custom type.
+
+2007-10-18  Tassilo Horn  <tassilo@member.fsf.org>
+
+	* doc-view.el (doc-view-dvi->pdf-sentinel, doc-view-dvi->pdf)
+	(doc-view-pdf/ps->png-sentinel, doc-view-pdf/ps->png)
+	(doc-view-pdf->txt-sentinel, doc-view-pdf->txt)
+	(doc-view-ps->pdf-sentinel, doc-view-ps->pdf): Remove superfluous
+	messages.
+	(doc-view-mode-map): Use the image-mode scrolling commands.  Don't
+	rebind C-x k.
+
+2007-10-18  Reiner Steib  <Reiner.Steib@gmx.de>
+
+	* doc-view.el (doc-view-ghostscript-options, doc-view-ps->pdf):
+	Add comment about "-dSAFER".
+
+2007-10-18  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* term/xterm.el: Don't require xt-mouse.
+	(terminal-init-xterm): Run terminal-init-xterm-hook rather than
+	calling turn-on-xterm-mouse-tracking-on-terminal directly.
+
+	* xt-mouse.el: Don't change the global function-key-map anny more.
+	(xterm-mouse-mode): Use terminal-init-xterm-hook.
+	Don't use after-make-frame-functions now that term/xterm.el calls
+	us directly.
+	(turn-on-xterm-mouse-tracking, turn-off-xterm-mouse-tracking):
+	Use turn-*-xterm-mouse-tracking-on-terminal.  Only once per terminal.
+	(turn-on-xterm-mouse-tracking-on-terminal): Make param optional.
+	Setup input-decode-map and remember that xterm-mouse-mode was
+	enabled in this terminal.
+	(turn-off-xterm-mouse-tracking-on-terminal): Only disable on those
+	terminals where it has been enabled.
+
+	* faces.el (tty-create-frame-with-faces): Make sure not only
+	tty-run-terminal-initialization but also set-locale-environment
+	are run only once per terminal.
+	(tty-run-terminal-initialization): Don't check if the terminal was
+	already initted.
+
+	* international/encoded-kb.el (encoded-kbd-setup-display): Be careful
+	not to remove keymaps that just happen to inherit from one of ours.
+	When setting up our keymap, make sure it won't be accidentally
+	modified by someone else.
+
+2007-10-18  Thien-Thi Nguyen  <ttn@gnuvola.org>
+
+	* textmodes/artist.el (artist-previous-line, artist-next-line):
+	* dired.el (dired-next-line, dired-previous-line):
+	* progmodes/delphi.el (delphi-newline):
+	* textmodes/org.el (org-columns-eval):
+	Use forward-line.
+
+	* emerge.el (emerge-setup): Use insert-buffer-substring.
+	(emerge-prepare-error-list, emerge-setup-with-ancestor): Likewise.
+
+2007-10-18  Juanma Barranquero  <lekktu@gmail.com>
+
+	* textmodes/fill.el (fill-individual-paragraphs): Doc fix.
+	(adaptive-fill-function): Doc fix.  Remove * from docstring.
+
+2007-10-18  Tom Horsley  <tom.horsley@att.net>
+
+	* simple.el (interprogram-paste-function): Doc fix.
+	(current-kill): Accept list of strings as well
+	as single string from `interprogram-paste-function'.
+
+2007-10-18  Glenn Morris  <rgm@gnu.org>
+
+	* ibuf-ext.el (ibuffer-saved-filter-groups): Doc fix.
+
+2007-10-18  Drew Adams  <drew.adams@oracle.com>
+
+	* bindings.el (mode-line-minor-mode-keymap):
+	Add mouse-minor-mode-menu on mouse-1.
+	(mode-line-modes): Add mouse-1 to help-echo text.
+	(mouse-minor-mode-menu, minor-mode-menu-from-indicator):
+	New functions.
+	(mode-line-minor-mode-help): Doc fix.
+
+2007-10-17  Juri Linkov  <juri@jurta.org>
+
+	* textmodes/fill.el (fill-paragraph-or-region): Remove function
+	at the request of RMS.
+	(fill-paragraph): Change `arg' to optional `justify'.  Add interactive
+	arg `region'.  Fix docstring.  At the first `or' branch add call to
+	`fill-region' if it the region is active in transient-mark-mode.
+
+	* bindings.el (esc-map): Bind M-q to fill-paragraph
+	instead of fill-paragraph-or-region.
+
+	* tutorial.el (tutorial--default-keys): Replace fill-paragraph-or-region
+	with fill-paragraph.
+
+	* textmodes/ispell.el (ispell-word): Add interactive arg `region'.
+	Fix docstring.
+
+	* indent.el (indent-for-tab-command): Change interactive spec from
+	"P" to "p".  Add check for interactive arg before indenting the
+	active region.
+
+	* files.el (auto-mode-alist): Add \\. before PDF/PS/DVI extensions.
+	Regroup.
+
+2007-10-17  Juanma Barranquero  <lekktu@gmail.com>
+
+	* emacs-lisp/find-func.el: Don't require loadhist.
+
+	* loadhist.el (feature-symbols, file-provides, file-requires)
+	(file-set-intersect, file-dependents): Simplify.
+	(unload-feature-special-hooks): Update list of special hooks.
+
+2007-10-17  Tassilo Horn  <tassilo@member.fsf.org>
+
+	* bindings.el (completion-ignored-extensions): Remove pdf and dvi
+	extensions since they can be viewed with doc-view.
+
+	* files.el (auto-mode-alist): Make doc-view-mode the default mode
+	for pdf, ps and dvi files.
+
+	* doc-view.el: Make doc-view-mode the standard mode for viewing
+	pdf, [e]ps and dvi files and add binding C-c C-c to toggle between
+	text and image display.  Add binding C-c C-e to switch to an
+	editing mode.
+	(doc-view-ghostscript-options, doc-view-ps->pdf): Add "-dSAFER" to
+	avoid security problems when rendering files from untrusted sources.
+
+2007-10-17  Aaron Hawley  <aaronh@garden.org>
+
+	* tutorial.el (tutorial--save-tutorial): Display message when tutorial
+	position is not saved.
+
+2007-10-17  Reiner Steib  <Reiner.Steib@gmx.de>
+
+	* doc-view.el: Mention xpdf.  Fix spelling of Ghostscript.
+	(doc-view-ghostscript-options): Fix typo in doc string.
+
+2007-10-17  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* progmodes/compile.el (compilation-next-error-function): Fix timestamp
+	handling, so compilation-fake-loc works again.
+
+	* server.el (server-select-display): Nop if we do not support m-f-o-d.
+	(server-process-filter): Revert last change.
+
+	* vc.el (vc-diff-sentinel, vc-diff-internal): Revert some change in the
+	behavior unrelated to filesets.
+
+2007-10-17  Chong Yidong  <cyd@stupidchicken.com>
+
+	* longlines.el (longlines-wrap-follows-window-size): Integer value
+	specifies wrapping margin.
+	(longlines-mode, longlines-window-change-function):
+	Set window-specific wrapping margin based on the above.
+
+2007-10-17  John Wiegley  <johnw@newartisans.com>
+
+	* eshell/esh-cmd.el (eshell-complex-commands): Add "ls".
+
+2007-10-17  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* server.el (server-process-filter): Only set display if X11 is
+	supported.
+
+2007-10-17  Glenn Morris  <rgm@gnu.org>
+
+	* progmodes/cc-menus.el (cc-imenu-c++-generic-expression):
+	Tweak regexp to avoid stack overflow.
+
+2007-10-16  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* simple.el (reindent-then-newline-and-indent): Don't assume that
+	indent-according-to-mode preserves point.
+
+2007-10-16  Juanma Barranquero  <lekktu@gmail.com>
+
+	* bs.el (bs--make-header-match-string, bs-show-in-buffer)
+	(bs--nth-wrapper): Simplify.
+	(bs-select, bs--insert-one-entry): Simplify.  Use `when'.
+	(bs-buffer-list): Simplify.  Use `when'.  Use `string-match-p'.
+	(bs-sort-buffer-interns-are-last): Use `string-match-p'.
+	(bs-attributes-list, bs-max-window-height, bs-must-always-show-regexp)
+	(bs-maximal-buffer-name-column, bs-minimal-buffer-name-column)
+	(bs-configurations, bs-default-configuration)
+	(bs-alternative-configuration, bs-cycle-configuration-name)
+	(bs-string-show-always, bs-string-show-never, bs-string-current)
+	(bs-string-current-marked, bs-string-marked, bs-string-show-normally)
+	(bs-sort-functions, bs-default-sort-name): Remove * in docstrings.
+	(bs--redisplay, bs--goto-current-buffer, bs--current-buffer, bs-delete)
+	(bs-apply-sort-faces, bs-next-config-aux): Use `when'.
+	(bs--window-config-coming-from): Revert 2006-11-09 change.
+	(bs--restore-window-config): Keep the selected frame.
+	(bs--track-window-changes, bs--remove-hooks): New functions.
+	(bs-mode): Use `define-derived-mode'.  Set hook to track window changes.
+	(bs--create-header): Remove.
+	(bs--create-header-line): New function, based on `bs--create-header'.
+	(bs--show-header): Use `bs--create-header-line'.
+	(bs--show-with-configuration): Revert 2006-11-09 change.
+	Don't reuse window unless it is visible on the selected frame.
+	Restore window configuration (possibly in a different frame)
+	before creating any window.
+
+2007-10-16  Glenn Morris  <rgm@gnu.org>
+
+	* simple.el (blink-matching-open): Don't report false errors with
+	the `$' syntax class.
+
+2007-10-16  Richard Stallman  <rms@gnu.org>
+
+	* emacs-lisp/advice.el (ad-get-advice-info): Change to a function.
+	(ad-get-advice-info-macro): New macro, like old ad-get-advice-info.
+	(ad-is-advised, ad-get-advice-info-field)
+	(ad-set-advice-info-field): Use ad-get-advice-info-macro.
+
+2007-10-15  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* vc-hooks.el (vc-workfile-version): Compatibility alias.
+	(vc-default-working-revision): Compatibility for backends.
+
+2007-10-15  Juanma Barranquero  <lekktu@gmail.com>
+
+	* filesets.el (filesets-alist-get): Use `let' rather than `let*'.
+	(filesets-ormap, filesets-sort-case-sensitive-flag)
+	(filesets-remake-shortcut, filesets-ingroup-collect-files):
+	Fix typos in docstrings.
+	(filesets-conditional-sort, filesets-find-or-display-file)
+	(filesets-data-get-name, filesets-data-get-data)
+	(filesets-data-set, filesets-cmd-query-replace-getargs)
+	(filesets-ingroup-collect): Doc fixes.
+
+2007-10-15  Sam Steingold  <sds@gnu.org>
+
+	* mail/sendmail.el (sendmail-error-reporting-interactive)
+	(sendmail-error-reporting-non-interactive): New variables for
+	sendmail error reporting options to simplify support for imperfect
+	sendmail emulators.
+	(sendmail-send-it): Use them instead of list literals.
+
+2007-10-15  Juanma Barranquero  <lekktu@gmail.com>
+
+	* help-fns.el: Revert previous change; it creates a
+	dependency loop between advice.el and help-fns.el.
+
+2007-10-15  Juanma Barranquero  <lekktu@gmail.com>
+
+	* help-fns.el: Require advice when compiling.
+
 2007-10-14  Drew Adams  <drew.adams@oracle.com>
 
 	* emacs-lisp/ring.el (ring-convert-sequence-to-ring)
@@ -99,8 +365,8 @@
 
 2007-10-13  Dan Nicolaescu  <dann@ics.uci.edu>
 
-	* frame.el (select-frame-set-input-focus): Fix typo
-	"max" -> "mac". Do not use a single clause cond.
+	* frame.el (select-frame-set-input-focus): Fix typo "max" -> "mac".
+	Do not use a single clause cond.
 
 	* cus-start.el (all): Use test that does not match the X11 version
 	for mac.
@@ -148,7 +414,7 @@
 	(idlwave-complete-in-buffer):
 	* textmodes/org.el (org-export-as-html, org-export-as-ascii)
 	(org-fast-tag-selection):
-	* textmodes/reftex-sel.el (reftex-select-item):  Use mapc rather
+	* textmodes/reftex-sel.el (reftex-select-item): Use mapc rather
 	than mapcar.
 
 2007-10-13  Dan Nicolaescu  <dann@ics.uci.edu>
@@ -170,9 +436,8 @@
 	and some leftover logic regarding dedicated frames.  If showing
 	concise startup screen, fit window to buffer.
 	(command-line-1): If we will be using the splash screen, use
-	find-file instead of find-file-other-window to find additional
-	files.  Comment out unused code for coping with the old sit-for
-	behavior.
+	find-file instead of find-file-other-window to find additional files.
+	Comment out unused code for coping with the old sit-for behavior.
 
 2007-10-12  Stefan Monnier  <monnier@iro.umontreal.ca>
 
--- a/lisp/bindings.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/bindings.el	Fri Oct 19 00:00:21 2007 +0000
@@ -289,6 +289,7 @@
 
 (defvar mode-line-minor-mode-keymap
   (let ((map (make-sparse-keymap)))
+    (define-key map [mode-line down-mouse-1] 'mouse-minor-mode-menu)
     (define-key map [mode-line mouse-2] 'mode-line-minor-mode-help)
     (define-key map [mode-line down-mouse-3] 'mode-line-mode-menu-1)
     (define-key map [header-line down-mouse-3] 'mode-line-mode-menu-1)
@@ -331,7 +332,7 @@
 	 '("" mode-line-process)
 	 `(:propertize ("" minor-mode-alist)
 		       mouse-face mode-line-highlight
-		       help-echo "mouse-2: minor mode help, mouse-3: toggle minor modes"
+		       help-echo "mouse-1: minor mode, mouse-2: minor mode help, mouse-3: toggle minor modes"
 		       local-map ,mode-line-minor-mode-keymap)
 	 (propertize "%n" 'help-echo "mouse-2: widen"
 		     'mouse-face 'mode-line-highlight
@@ -492,8 +493,28 @@
   (interactive "@e")
   (x-popup-menu event mode-line-mode-menu))
 
+(defun mouse-minor-mode-menu (event)
+  "Show minor-mode menu for EVENT on minor modes area of the mode line."
+  (interactive "@e")
+  (let ((indicator (car (nth 4 (car (cdr event))))))
+    (minor-mode-menu-from-indicator indicator)))
+
+(defun minor-mode-menu-from-indicator (indicator)
+  "Show menu, if any, for minor mode specified by INDICATOR.
+Interactively, INDICATOR is read using completion."
+  (interactive (list (completing-read "Minor mode indicator: "
+                                      (describe-minor-mode-completion-table-for-indicator))))
+  (let ((minor-mode (lookup-minor-mode-from-indicator indicator)))
+    (if minor-mode
+        (let* ((map (cdr-safe (assq minor-mode minor-mode-map-alist)))
+               (menu (and (keymapp map) (lookup-key map [menu-bar]))))
+          (if menu
+              (popup-menu menu)
+            (message "No menu for minor mode `%s'" minor-mode)))
+      (error "Cannot find minor mode for `%s'" indicator))))
+
 (defun mode-line-minor-mode-help (event)
-  "Describe minor mode for EVENT occurred on minor modes area of the mode line."
+  "Describe minor mode for EVENT on minor modes area of the mode line."
   (interactive "@e")
   (let ((indicator (car (nth 4 (car (cdr event))))))
     (describe-minor-mode-from-indicator indicator)))
@@ -536,7 +557,7 @@
        '(".elc" ".lof"
 	 ".glo" ".idx" ".lot"
 	 ;; TeX-related
-	 ".dvi" ".fmt" ".tfm" ".pdf"
+	 ".fmt" ".tfm"
 	 ;; Java compiled
 	 ".class"
 	 ;; CLISP
@@ -1035,7 +1056,7 @@
 (define-key ctl-x-map "rw" 'window-configuration-to-register)
 (define-key ctl-x-map "rf" 'frame-configuration-to-register)
 
-(define-key esc-map "q" 'fill-paragraph-or-region)
+(define-key esc-map "q" 'fill-paragraph)
 (define-key ctl-x-map "." 'set-fill-prefix)
 
 (define-key esc-map "{" 'backward-paragraph)
--- a/lisp/bs.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/bs.el	Fri Oct 19 00:00:21 2007 +0000
@@ -158,7 +158,7 @@
     (""       2   2 left  "  ")
     ("File"   12 12 left  bs--get-file-name)
     (""       2   2 left  "  "))
-  "*List specifying the layout of a Buffer Selection Menu buffer.
+  "List specifying the layout of a Buffer Selection Menu buffer.
 Each entry specifies a column and is a list of the form of:
 \(HEADER MINIMUM-LENGTH MAXIMUM-LENGTH ALIGNMENT FUN-OR-STRING)
 
@@ -180,12 +180,7 @@
 
 (defun bs--make-header-match-string ()
   "Return a regexp matching the first line of a Buffer Selection Menu buffer."
-  (let ((res "^\\(")
-	(ele bs-attributes-list))
-    (while ele
-      (setq res (concat res (car (car ele)) " *"))
-      (setq ele (cdr ele)))
-    (concat res "$\\)")))
+  (concat "^\\(" (mapconcat #'car bs-attributes-list " *") " *$\\)"))
 
 ;; Font-Lock-Settings
 (defvar bs-mode-font-lock-keywords
@@ -206,7 +201,7 @@
   "Default font lock expressions for Buffer Selection Menu.")
 
 (defcustom bs-max-window-height 20
-  "*Maximal window height of Buffer Selection Menu."
+  "Maximal window height of Buffer Selection Menu."
   :group 'bs-appearance
   :type 'integer)
 
@@ -224,7 +219,7 @@
 that must always be shown regardless of the configuration.")
 
 (defcustom bs-must-always-show-regexp nil
-  "*Regular expression for specifying buffers to show always.
+  "Regular expression for specifying buffers to show always.
 A buffer whose name matches this regular expression will
 be shown regardless of current configuration of Buffer Selection Menu."
   :group 'bs
@@ -246,7 +241,7 @@
 It must return non-nil if the first buffer should sort before the second.")
 
 (defcustom bs-maximal-buffer-name-column 45
-  "*Maximum column width for buffer names.
+  "Maximum column width for buffer names.
 The column for buffer names has dynamic width.  The width depends on
 maximal and minimal length of names of buffers to show.  The maximal
 width is bounded by `bs-maximal-buffer-name-column'.
@@ -255,7 +250,7 @@
   :type 'integer)
 
 (defcustom bs-minimal-buffer-name-column 15
-  "*Minimum column width for buffer names.
+  "Minimum column width for buffer names.
 The column for buffer names has dynamic width.  The width depends on
 maximal and minimal length of names of buffers to show.  The minimal
 width is bounded by `bs-minimal-buffer-name-column'.
@@ -272,7 +267,7 @@
     ("files-and-scratch" "^\\*scratch\\*$" nil nil bs-visits-non-file
      bs-sort-buffer-interns-are-last)
     ("all-intern-last" nil nil nil nil bs-sort-buffer-interns-are-last))
-  "*List of all configurations you can use in the Buffer Selection Menu.
+  "List of all configurations you can use in the Buffer Selection Menu.
 A configuration describes which buffers appear in Buffer Selection Menu
 and also the order of buffers.  A configuration is a list with
 six elements.  The first element is a string and describes the configuration.
@@ -284,7 +279,7 @@
   :type '(repeat sexp))
 
 (defcustom bs-default-configuration "files"
-  "*Name of default configuration used by the Buffer Selection Menu.
+  "Name of default configuration used by the Buffer Selection Menu.
 \\<bs-mode-map>
 Will be changed using key \\[bs-select-next-configuration].
 Must be a string used in `bs-configurations' for naming a configuration."
@@ -292,7 +287,7 @@
   :type 'string)
 
 (defcustom bs-alternative-configuration "all"
-  "*Name of configuration used when calling `bs-show' with \
+  "Name of configuration used when calling `bs-show' with \
 \\[universal-argument] as prefix key.
 Must be a string used in `bs-configurations' for naming a configuration."
   :group 'bs
@@ -303,7 +298,7 @@
 Must be a string used in `bs-configurations' for naming a configuration.")
 
 (defcustom bs-cycle-configuration-name nil
-  "*Name of configuration used when cycling through the buffer list.
+  "Name of configuration used when cycling through the buffer list.
 A value of nil means to use current configuration `bs-default-configuration'.
 Must be a string used in `bs-configurations' for naming a configuration."
   :group 'bs
@@ -311,32 +306,32 @@
    string))
 
 (defcustom bs-string-show-always "+"
-  "*String added in column 1 indicating a buffer will always be shown."
+  "String added in column 1 indicating a buffer will always be shown."
   :group 'bs-appearance
   :type 'string)
 
 (defcustom bs-string-show-never "-"
-  "*String added in column 1 indicating a buffer will never be shown."
+  "String added in column 1 indicating a buffer will never be shown."
   :group 'bs-appearance
   :type 'string)
 
 (defcustom bs-string-current "."
-  "*String added in column 1 indicating the current buffer."
+  "String added in column 1 indicating the current buffer."
   :group 'bs-appearance
   :type 'string)
 
 (defcustom bs-string-current-marked "#"
-  "*String added in column 1 indicating the current buffer when it is marked."
+  "String added in column 1 indicating the current buffer when it is marked."
   :group 'bs-appearance
   :type 'string)
 
 (defcustom bs-string-marked ">"
-  "*String added in column 1 indicating a marked buffer."
+  "String added in column 1 indicating a marked buffer."
   :group 'bs-appearance
   :type 'string)
 
 (defcustom bs-string-show-normally  " "
-  "*String added in column 1 indicating an unmarked buffer."
+  "String added in column 1 indicating an unmarked buffer."
   :group 'bs-appearance
   :type 'string)
 
@@ -390,7 +385,7 @@
     ("by mode"     bs--sort-by-mode     "Mode"   region)
     ("by filename" bs--sort-by-filename "File"   region)
     ("by nothing"  nil                  nil      nil))
-  "*List of all possible sorting aspects for Buffer Selection Menu.
+  "List of all possible sorting aspects for Buffer Selection Menu.
 You can add a new entry with a call to `bs-define-sort-function'.
 Each element is a list of four elements (NAME FUNCTION REGEXP-FOR-SORTING FACE).
 NAME specifies the sort order defined by function FUNCTION.
@@ -425,7 +420,7 @@
 This is an element of `bs-sort-functions'.")
 
 (defcustom bs-default-sort-name "by nothing"
-  "*Name of default sort behavior.
+  "Name of default sort behavior.
 Must be \"by nothing\" or a string used in `bs-sort-functions' for
 naming a sort behavior.  Default is \"by nothing\" which means no sorting."
   :group 'bs
@@ -445,7 +440,6 @@
 
 (defvar bs--window-config-coming-from nil
   "Window configuration before starting Buffer Selection Menu.")
-(make-variable-frame-local 'bs--window-config-coming-from)
 
 (defvar bs--intern-show-never "^ \\|\\*buffer-selection\\*"
   "Regular expression specifying which buffers never to show.
@@ -529,45 +523,43 @@
   (setq sort-description (or sort-description bs--current-sort-function)
 	list (or list (buffer-list)))
   (let ((result nil))
-    (while list
-      (let* ((buffername (buffer-name (car list)))
-	     (int-show-never (string-match bs--intern-show-never buffername))
+    (dolist (buf list)
+      (let* ((buffername (buffer-name buf))
+	     (int-show-never (string-match-p bs--intern-show-never buffername))
 	     (ext-show-never (and bs-dont-show-regexp
-				  (string-match bs-dont-show-regexp
-						buffername)))
+				  (string-match-p bs-dont-show-regexp
+						  buffername)))
 	     (extern-must-show (or (and bs-must-always-show-regexp
-					(string-match
+					(string-match-p
 					 bs-must-always-show-regexp
 					 buffername))
 				   (and bs-must-show-regexp
-					(string-match bs-must-show-regexp
-						      buffername))))
+					(string-match-p bs-must-show-regexp
+							buffername))))
 	     (extern-show-never-from-fun (and bs-dont-show-function
 					      (funcall bs-dont-show-function
-						       (car list))))
+						       buf)))
 	     (extern-must-show-from-fun (and bs-must-show-function
 					     (funcall bs-must-show-function
-						      (car list))))
-	     (show-flag (buffer-local-value 'bs-buffer-show-mark (car list))))
-	(if (or (eq show-flag 'always)
-		(and (or bs--show-all (not (eq show-flag 'never)))
-		     (not int-show-never)
-		     (or bs--show-all
-			 extern-must-show
-			 extern-must-show-from-fun
-			 (and (not ext-show-never)
-			      (not extern-show-never-from-fun)))))
-	    (setq result (cons (car list)
-			       result)))
-	(setq list (cdr list))))
+						      buf)))
+	     (show-flag (buffer-local-value 'bs-buffer-show-mark buf)))
+	(when (or (eq show-flag 'always)
+		  (and (or bs--show-all (not (eq show-flag 'never)))
+		       (not int-show-never)
+		       (or bs--show-all
+			   extern-must-show
+			   extern-must-show-from-fun
+			   (and (not ext-show-never)
+				(not extern-show-never-from-fun)))))
+	  (setq result (cons buf result)))))
     (setq result (reverse result))
     ;; The current buffer which was the start point of bs should be an element
     ;; of result list, so that we can leave with space and be back in the
     ;; buffer we started bs-show.
-    (if (and bs--buffer-coming-from
-	     (buffer-live-p bs--buffer-coming-from)
-	     (not (memq bs--buffer-coming-from result)))
-	(setq result (cons bs--buffer-coming-from result)))
+    (when (and bs--buffer-coming-from
+	       (buffer-live-p bs--buffer-coming-from)
+	       (not (memq bs--buffer-coming-from result)))
+      (setq result (cons bs--buffer-coming-from result)))
     ;; sorting
     (if (and sort-description
 	     (nth 1 sort-description))
@@ -587,8 +579,8 @@
 SORT-DESCRIPTION is an element of `bs-sort-functions'."
   (let ((line (1+ (count-lines 1 (point)))))
     (bs-show-in-buffer (bs-buffer-list nil sort-description))
-    (if keep-line-p
-	(goto-line line))
+    (when keep-line-p
+      (goto-line line))
     (beginning-of-line)))
 
 (defun bs--goto-current-buffer ()
@@ -602,10 +594,10 @@
 	point)
     (save-excursion
       (goto-char (point-min))
-      (if (search-forward-regexp regexp nil t)
-	  (setq point (- (point) 1))))
-    (if point
-	(goto-char point))))
+      (when (search-forward-regexp regexp nil t)
+	(setq point (1- (point)))))
+    (when point
+      (goto-char point))))
 
 (defun bs--current-config-message ()
   "Return a string describing the current `bs-mode' configuration."
@@ -614,7 +606,23 @@
     (format "Show buffer by configuration %S"
 	    bs-current-configuration)))
 
-(defun bs-mode ()
+(defun bs--track-window-changes (frame)
+  "Track window changes to refresh the buffer list.
+Used from `window-size-change-functions'."
+  (let ((win (get-buffer-window "*buffer-selection*" frame)))
+    (when win
+      (with-selected-window win
+	(bs-refresh)
+	(bs--set-window-height)))))
+
+(defun bs--remove-hooks ()
+  "Remove `bs--track-window-changes' and auxiliary hooks."
+  (remove-hook 'window-size-change-functions 'bs--track-window-changes)
+  ;; Remove itself
+  (remove-hook 'kill-buffer-hook 'bs--remove-hooks t)
+  (remove-hook 'change-major-mode-hook 'bs--remove-hooks t))
+
+(define-derived-mode bs-mode nil "Buffer-Selection-Menu"
   "Major mode for editing a subset of Emacs' buffers.
 \\<bs-mode-map>
 Aside from two header lines each line describes one buffer.
@@ -647,27 +655,27 @@
 to show always.
 \\[bs-visit-tags-table] -- call `visit-tags-table' on current line's buffer.
 \\[bs-help] -- display this help text."
-  (interactive)
-  (kill-all-local-variables)
-  (use-local-map bs-mode-map)
   (make-local-variable 'font-lock-defaults)
   (make-local-variable 'font-lock-verbose)
   (make-local-variable 'font-lock-global-modes)
   (buffer-disable-undo)
-  (setq major-mode 'bs-mode
-	mode-name "Buffer-Selection-Menu"
-	buffer-read-only t
+  (setq buffer-read-only t
 	truncate-lines t
 	show-trailing-whitespace nil
 	font-lock-global-modes '(not bs-mode)
 	font-lock-defaults '(bs-mode-font-lock-keywords t)
 	font-lock-verbose nil)
-  (run-mode-hooks 'bs-mode-hook))
+  (add-hook 'window-size-change-functions 'bs--track-window-changes)
+  (add-hook 'kill-buffer-hook 'bs--remove-hooks nil t)
+  (add-hook 'change-major-mode-hook 'bs--remove-hooks nil t))
 
 (defun bs--restore-window-config ()
   "Restore window configuration on the current frame."
   (when bs--window-config-coming-from
-    (set-window-configuration bs--window-config-coming-from)
+    (let ((frame (selected-frame)))
+      (unwind-protect
+	   (set-window-configuration bs--window-config-coming-from)
+	(select-frame frame)))
     (setq bs--window-config-coming-from nil)))
 
 (defun bs-kill ()
@@ -705,8 +713,8 @@
   (beginning-of-line)
   (let ((line (+ (- bs-header-lines-length)
 		 (count-lines 1 (point)))))
-    (if (< line 0)
-	(error "You are on a header row"))
+    (when (< line 0)
+      (error "You are on a header row"))
     (nth line bs-current-list)))
 
 (defun bs--update-current-line ()
@@ -736,19 +744,18 @@
     (bury-buffer (current-buffer))
     (bs--restore-window-config)
     (switch-to-buffer buffer)
-    (if bs--marked-buffers
-	;; Some marked buffers for selection
-	(let* ((all (delq buffer bs--marked-buffers))
-	       (height (/ (1- (frame-height)) (1+ (length all)))))
-	  (delete-other-windows)
-	  (switch-to-buffer buffer)
-	  (while all
-	    (split-window nil height)
-	    (other-window 1)
-	    (switch-to-buffer (car all))
-	    (setq all (cdr all)))
-	  ;; goto window we have started bs.
-	  (other-window 1)))))
+    (when bs--marked-buffers
+      ;; Some marked buffers for selection
+      (let* ((all (delq buffer bs--marked-buffers))
+	     (height (/ (1- (frame-height)) (1+ (length all)))))
+	(delete-other-windows)
+	(switch-to-buffer buffer)
+	(dolist (buf all)
+	  (split-window nil height)
+	  (other-window 1)
+	  (switch-to-buffer buf))
+	;; goto window we have started bs.
+	(other-window 1)))))
 
 (defun bs-select-other-window ()
   "Select current line's buffer by `switch-to-buffer-other-window'.
@@ -912,11 +919,10 @@
     (delete-region (point) (save-excursion
 			     (end-of-line)
 			     (if (eobp) (point) (1+ (point)))))
-    (if (eobp)
-	(progn
-	  (backward-delete-char 1)
-	  (beginning-of-line)
-	  (recenter -1)))
+    (when (eobp)
+      (backward-delete-char 1)
+      (beginning-of-line)
+      (recenter -1))
     (bs--set-window-height)))
 
 (defun bs-delete-backward ()
@@ -945,14 +951,14 @@
 			      bs--current-sort-function)))
     (save-excursion
       (goto-char (point-min))
-      (if (and (nth 2 sort-description)
-	       (search-forward-regexp (nth 2 sort-description) nil t))
-	  (let ((inhibit-read-only t))
-	    (put-text-property (match-beginning 0)
-			       (match-end 0)
-			       'face
-			       (or (nth 3 sort-description)
-				   'region)))))))
+      (when (and (nth 2 sort-description)
+		 (search-forward-regexp (nth 2 sort-description) nil t))
+	(let ((inhibit-read-only t))
+	  (put-text-property (match-beginning 0)
+			     (match-end 0)
+			     'face
+			     (or (nth 3 sort-description)
+				 'region)))))))
 
 (defun bs-toggle-show-all ()
   "Toggle show all buffers / show buffers with current configuration."
@@ -983,10 +989,8 @@
 
 (defun bs--nth-wrapper (count fun &rest args)
   "Call COUNT times function FUN with arguments ARGS."
-  (setq count (or count 1))
-  (while (> count 0)
-    (apply fun args)
-    (setq count (1- count))))
+  (dotimes (i (or count 1))
+    (apply fun args)))
 
 (defun bs-up (arg)
   "Move cursor vertically up ARG lines in Buffer Selection Menu."
@@ -1026,7 +1030,7 @@
 
 (defun bs-sort-buffer-interns-are-last (b1 b2)
   "Function for sorting internal buffers at the end of all buffers."
-  (string-match "^\\*" (buffer-name b2)))
+  (string-match-p "^\\*" (buffer-name b2)))
 
 ;; ----------------------------------------------------------------------
 ;; Configurations:
@@ -1108,8 +1112,8 @@
 	(length (length list))
 	pos)
     (while (and assocs (not pos))
-      (if (string= (car (car assocs)) start-name)
-	  (setq pos (- length (length assocs))))
+      (when (string= (car (car assocs)) start-name)
+	(setq pos (- length (length assocs))))
       (setq assocs (cdr assocs)))
     (setq pos (1+ pos))
     (if (eq pos length)
@@ -1151,10 +1155,9 @@
     (erase-buffer)
     (setq bs--name-entry-length name-entry-length)
     (bs--show-header)
-    (while list
-      (bs--insert-one-entry (car list))
-      (insert "\n")
-      (setq list (cdr list)))
+    (dolist (buffer list)
+      (bs--insert-one-entry buffer)
+      (insert "\n"))
     (delete-backward-char 1)
     (bs--set-window-height)
     (bs--goto-current-buffer)
@@ -1348,27 +1351,21 @@
 and evaluates corresponding string.  Inserts string in current buffer;
 normally *buffer-selection*."
   (let ((string "")
-	(columns bs-attributes-list)
 	(to-much 0)
         (apply-args (append (list bs--buffer-coming-from bs-current-list))))
     (save-excursion
-      (while columns
-	(set-buffer buffer)
-	(let ((min   (bs--get-value (nth 1 (car columns))))
-	      ;;(max   (bs--get-value (nth 2 (car columns)))) refered no more
-	      (align (nth 3 (car columns)))
-	      (fun   (nth 4 (car columns)))
-	      (val   nil)
-	      new-string)
-	  (setq val (bs--get-value fun apply-args))
-	  (setq new-string (bs--format-aux val align (- min to-much)))
+      (set-buffer buffer)
+      (dolist (column bs-attributes-list)
+	(let* ((min (bs--get-value (nth 1 column)))
+	       (new-string (bs--format-aux (bs--get-value (nth 4 column) ; fun
+							  apply-args)
+					   (nth 3 column)                ; align
+					   (- min to-much)))
+	       (len (length new-string)))
 	  (setq string (concat string new-string))
-	  (if (> (length new-string) min)
-	      (setq to-much (- (length new-string) min)))
-	  )				; let
-	(setq columns (cdr columns))))
-    (insert string)
-    string))
+	  (when (> len min)
+	    (setq to-much (- len min))))))
+    (insert string)))
 
 (defun bs--format-aux (string align len)
   "Pad STRING to length LEN with alignment ALIGN.
@@ -1382,28 +1379,26 @@
 
 (defun bs--show-header ()
   "Insert header for Buffer Selection Menu in current buffer."
-  (dolist (string (bs--create-header))
-    (insert string "\n")))
+  (insert (bs--create-header-line #'identity)
+	  "\n"
+	  (bs--create-header-line (lambda (title)
+				    (make-string (length title) ?-)))
+	  "\n"))
 
 (defun bs--get-name-length ()
   "Return value of `bs--name-entry-length'."
   bs--name-entry-length)
 
-(defun bs--create-header ()
-  "Return all header lines used in Buffer Selection Menu as a list of strings."
-  (list (mapconcat (lambda (column)
-		     (bs--format-aux (bs--get-value (car column))
-				     (nth 3 column) ; align
-				     (bs--get-value (nth 1 column))))
-		   bs-attributes-list
-		   "")
-	(mapconcat (lambda (column)
-		     (let ((length (length (bs--get-value (car column)))))
-		       (bs--format-aux (make-string length ?-)
-				       (nth 3 column) ; align
-				       (bs--get-value (nth 1 column)))))
-		   bs-attributes-list
-		   "")))
+(defun bs--create-header-line (col)
+  "Generate a line for the header.
+COL is called for each column in `bs-attributes-list' as a
+function of one argument, the string heading for the column."
+  (mapconcat (lambda (column)
+	       (bs--format-aux (funcall col (bs--get-value (car column)))
+			       (nth 3 column) ; align
+			       (bs--get-value (nth 1 column))))
+	     bs-attributes-list
+	     ""))
 
 (defun bs--show-with-configuration (name &optional arg)
   "Display buffer list of configuration with name NAME.
@@ -1424,14 +1419,14 @@
       (setq bs--buffer-coming-from (current-buffer)))
     (let ((liste (bs-buffer-list))
 	  (active-window (get-window-with-predicate
-                          (lambda (w)
-                            (string= (buffer-name (window-buffer w))
-                                     "*buffer-selection*")))))
+			  (lambda (w)
+			    (string= (buffer-name (window-buffer w))
+				     "*buffer-selection*"))
+			  nil (selected-frame))))
       (if active-window
 	  (select-window active-window)
-        (modify-frame-parameters nil
-                                 (list (cons 'bs--window-config-coming-from
-                                             (current-window-configuration))))
+	(bs--restore-window-config)
+	(setq bs--window-config-coming-from (current-window-configuration))
 	(when (> (window-height (selected-window)) 7)
           (split-window-vertically)
           (other-window 1)))
--- a/lisp/dired.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/dired.el	Fri Oct 19 00:00:21 2007 +0000
@@ -1682,14 +1682,14 @@
   "Move down lines then position at filename.
 Optional prefix ARG says how many lines to move; default is one line."
   (interactive "p")
-  (next-line arg)
+  (forward-line arg)
   (dired-move-to-filename))
 
 (defun dired-previous-line (arg)
   "Move up lines then position at filename.
 Optional prefix ARG says how many lines to move; default is one line."
   (interactive "p")
-  (previous-line arg)
+  (forward-line (- arg))
   (dired-move-to-filename))
 
 (defun dired-next-dirline (arg &optional opoint)
--- a/lisp/doc-view.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/doc-view.el	Fri Oct 19 00:00:21 2007 +0000
@@ -5,7 +5,6 @@
 ;; Author: Tassilo Horn <tassilo@member.fsf.org>
 ;; Maintainer: Tassilo Horn <tassilo@member.fsf.org>
 ;; Keywords: files, pdf, ps, dvi
-;; Version: <2007-10-02 Tue 18:21>
 
 ;; This file is part of GNU Emacs.
 
@@ -26,9 +25,9 @@
 
 ;;; Requirements:
 
-;; doc-view.el requires GNU Emacs 22.1 or newer.  You also need GhostScript,
-;; `dvipdfm' which comes with TeTeX and `pdftotext', which comes with poppler
-;; (http://poppler.freedesktop.org/).
+;; doc-view.el requires GNU Emacs 22.1 or newer.  You also need Ghostscript,
+;; `dvipdfm' which comes with teTeX and `pdftotext', which comes with xpdf
+;; (http://www.foolabs.com/xpdf/) or poppler (http://poppler.freedesktop.org/).
 
 ;;; Commentary:
 
@@ -37,16 +36,19 @@
 ;; inside an Emacs buffer.  This buffer uses `doc-view-mode' which provides
 ;; convenient key bindings for browsing the document.
 ;;
-;; To use it simply do
+;; To use it simply open a document file with
+;;
+;;     C-x C-f ~/path/to/document RET
 ;;
-;;     M-x doc-view RET
-;;
-;; and you'll be queried for a document to open.
+;; and the document will be converted and displayed, if your emacs supports png
+;; images.  With `C-c C-c' you can toggle between the rendered images
+;; representation and the source text representation of the document.  With
+;; `C-c C-e' you can switch to an appropriate editing mode for the document.
 ;;
 ;; Since conversion may take some time all the PNG images are cached in a
 ;; subdirectory of `doc-view-cache-directory' and reused when you want to view
-;; that file again.  This reusing can be omitted if you provide a prefx
-;; argument to `doc-view'.  To delete all cached files use
+;; that file again.  To reconvert a document hit `g' (`doc-view-reconvert-doc')
+;; when displaying the document.  To delete all cached files use
 ;; `doc-view-clear-cache'.  To open the cache with dired, so that you can tidy
 ;; it out use `doc-view-dired-cache'.
 ;;
@@ -67,8 +69,6 @@
 ;; bottom-right corner of the desired slice.  To reset the slice use
 ;; `doc-view-reset-slice' (bound to `s r').
 ;;
-;; Dired users should have a look at `doc-view-dired'.
-;;
 ;; You can also search within the document.  The command `doc-view-search'
 ;; (bound to `C-s') queries for a search regexp and initializes a list of all
 ;; matching pages and messages how many match-pages were found.  After that you
@@ -80,17 +80,16 @@
 ;; conversion.  When that finishes and you're still viewing the document
 ;; (i.e. you didn't switch to another buffer) you're queried for the regexp
 ;; then.
+;;
+;; Dired users can simply hit `v' on a document file.  If it's a PS, PDF or DVI
+;; it will be opened using `doc-view-mode'.
+;;
 
 ;;; Configuration:
 
-;; Basically doc-view should be quite usable with its standard settings, so
-;; putting
-;;
-;;     (require 'doc-view)
-;;
-;; into your `user-init-file' should be enough.  If the images are too small or
-;; too big you should set the "-rXXX" option in `doc-view-ghostscript-options'
-;; to another value.  (The bigger your screen, the higher the value.)
+;; If the images are too small or too big you should set the "-rXXX" option in
+;; `doc-view-ghostscript-options' to another value.  (The bigger your screen,
+;; the higher the value.)
 ;;
 ;; This and all other options can be set with the customization interface.
 ;; Simply do
@@ -102,6 +101,7 @@
 ;;; Code:
 
 (require 'dired)
+(require 'image-mode)
 (eval-when-compile (require 'cl))
 
 ;;;; Customization Options
@@ -114,50 +114,51 @@
   :group 'multimedia
   :prefix "doc-view-")
 
-(defcustom doc-view-ghostscript-program "gs"
+(defcustom doc-view-ghostscript-program (executable-find "gs")
   "Program to convert PS and PDF files to PNG."
-  :type '(file)
+  :type 'file
   :group 'doc-view)
 
 (defcustom doc-view-ghostscript-options
-  '("-dNOPAUSE" "-sDEVICE=png16m" "-dTextAlphaBits=4"
-    "-dBATCH" "-dGraphicsAlphaBits=4" "-dQUIET"
-    "-r100")
-  "A list of options to give to ghostview."
-  :type '(sexp)
+  '("-dSAFER" ;; Avoid security problems when rendering files from untrusted
+	      ;; sources.
+    "-dNOPAUSE" "-sDEVICE=png16m" "-dTextAlphaBits=4"
+    "-dBATCH" "-dGraphicsAlphaBits=4" "-dQUIET" "-r100")
+  "A list of options to give to ghostscript."
+  :type '(repeat string)
   :group 'doc-view)
 
-(defcustom doc-view-dvipdfm-program "dvipdfm"
+(defcustom doc-view-dvipdfm-program (executable-find "dvipdfm")
   "Program to convert DVI files to PDF.
 
 DVI file will be converted to PDF before the resulting PDF is
 converted to PNG."
-  :type '(file)
+  :type 'file
   :group 'doc-view)
 
-(defcustom doc-view-ps2pdf-program "ps2pdf"
+(defcustom doc-view-ps2pdf-program (executable-find "ps2pdf")
   "Program to convert PS files to PDF.
 
 PS files will be converted to PDF before searching is possible."
-  :type '(file)
+  :type 'file
   :group 'doc-view)
 
-(defcustom doc-view-pdftotext-program "pdftotext"
+(defcustom doc-view-pdftotext-program (executable-find "pdftotext")
   "Program to convert PDF files to plain text.
 
 Needed for searching."
-  :type '(file)
+  :type 'file
   :group 'doc-view)
 
 (defcustom doc-view-cache-directory (concat temporary-file-directory
 					    "doc-view")
   "The base directory, where the PNG images will be saved."
-  :type '(directory)
+  :type 'directory
   :group 'doc-view)
 
 (defcustom doc-view-conversion-buffer "*doc-view conversion output*"
   "The buffer where messages from the converter programs go to."
-  :type '(string)
+  :type 'string
   :group 'doc-view)
 
 (defcustom doc-view-conversion-refresh-interval 3
@@ -166,7 +167,7 @@
 viewing.  If set to nil there won't be any refreshes and the
 pages won't be displayed before conversion of the whole document
 has finished."
-  :type '(string)
+  :type 'integer
   :group 'doc-view)
 
 ;;;; Internal Variables
@@ -201,7 +202,10 @@
 (defvar doc-view-current-info nil
   "Only used internally.")
 
-;;;; DocView Keymap
+(defvar doc-view-current-display nil
+  "Only used internally.")
+
+;;;; DocView Keymaps
 
 (defvar doc-view-mode-map
   (let ((map (make-sparse-keymap)))
@@ -218,7 +222,6 @@
     ;; Killing/burying the buffer (and the process)
     (define-key map (kbd "q")         'bury-buffer)
     (define-key map (kbd "k")         'doc-view-kill-proc-and-buffer)
-    (define-key map (kbd "C-x k")     'doc-view-kill-proc-and-buffer)
     ;; Slicing the image
     (define-key map (kbd "s s")       'doc-view-set-slice)
     (define-key map (kbd "s m")       'doc-view-set-slice-using-mouse)
@@ -229,15 +232,40 @@
     (define-key map (kbd "C-S-n")     'doc-view-search-next-match)
     (define-key map (kbd "C-S-p")     'doc-view-search-previous-match)
     ;; Scrolling
+    (define-key map (kbd "<right>")   'image-forward-hscroll)
+    (define-key map (kbd "<left>")    'image-backward-hscroll)
+    (define-key map (kbd "<down>")    'image-next-line)
+    (define-key map (kbd "<up>")      'image-previous-line)
+    (define-key map (kbd "C-f")       'image-forward-hscroll)
+    (define-key map (kbd "C-b")       'image-backward-hscroll)
+    (define-key map (kbd "C-n")       'image-next-line)
+    (define-key map (kbd "C-p")       'image-previous-line)
     (define-key map (kbd "C-v")       'scroll-up)
     (define-key map (kbd "<mouse-4>") 'mwheel-scroll)
     (define-key map (kbd "<mouse-5>") 'mwheel-scroll)
     (define-key map (kbd "M-v")       'scroll-down)
     ;; Show the tooltip
     (define-key map (kbd "C-t")       'doc-view-show-tooltip)
+    ;; Toggle between text and image display or editing
+    (define-key map (kbd "C-c C-c")   'doc-view-toggle-display)
+    (define-key map (kbd "C-c C-e")   'doc-view-edit-doc)
+    ;; Reconvert the current document
+    (define-key map (kbd "g")         'doc-view-reconvert-doc)
     (suppress-keymap map)
     map)
-  "Keymap used by `doc-view-mode'.")
+  "Keymap used by `doc-view-mode' when displaying a doc as a set of images.")
+
+(defvar doc-view-mode-text-map
+  (let ((map (make-sparse-keymap)))
+    ;; Toggle between text and image display or editing
+    (define-key map (kbd "C-c C-c") 'doc-view-toggle-display)
+    (define-key map (kbd "C-c C-e") 'doc-view-edit-doc)
+    ;; Killing/burying the buffer (and the process)
+    (define-key map (kbd "q")         'bury-buffer)
+    (define-key map (kbd "k")         'doc-view-kill-proc-and-buffer)
+    (define-key map (kbd "C-x k")     'doc-view-kill-proc-and-buffer)
+    map)
+  "Keymap used by `doc-view-mode' when displaying a document as text.")
 
 ;;;; Navigation Commands
 
@@ -271,16 +299,16 @@
 			 (setq contexts (concat contexts "  - \"" m "\"\n")))
 		       contexts)))))
     ;; Update the buffer
-    (setq inhibit-read-only t)
-    (erase-buffer)
-    (let ((beg (point)))
-      (doc-view-insert-image (nth (1- page) doc-view-current-files)
-			     :pointer 'arrow)
-      (put-text-property beg (point) 'help-echo doc-view-current-info))
-    (insert "\n" doc-view-current-info)
-    (goto-char (point-min))
-    (forward-char)
-    (setq inhibit-read-only nil)))
+    (let ((inhibit-read-only t))
+      (erase-buffer)
+      (let ((beg (point)))
+	(doc-view-insert-image (nth (1- page) doc-view-current-files)
+			       :pointer 'arrow)
+	(put-text-property beg (point) 'help-echo doc-view-current-info))
+      (insert "\n" doc-view-current-info)
+      (goto-char (point-min))
+      (forward-char))
+    (set-buffer-modified-p nil)))
 
 (defun doc-view-next-page (&optional arg)
   "Browse ARG pages forward."
@@ -317,52 +345,71 @@
     (error (doc-view-previous-page)
 	   (goto-char (point-max)))))
 
+(defun doc-view-kill-proc ()
+  "Kill the current converter process."
+  (interactive)
+  (when doc-view-current-converter-process
+    (kill-process doc-view-current-converter-process))
+  (when doc-view-current-timer
+    (cancel-timer doc-view-current-timer)
+    (setq doc-view-current-timer nil))
+  (setq mode-line-process nil))
+
 (defun doc-view-kill-proc-and-buffer ()
   "Kill the current converter process and buffer."
   (interactive)
+  (doc-view-kill-proc)
   (when (eq major-mode 'doc-view-mode)
-    (when doc-view-current-converter-process
-      (kill-process doc-view-current-converter-process))
-    (when doc-view-current-timer
-      (cancel-timer doc-view-current-timer)
-      (setq doc-view-current-timer nil))
     (kill-buffer (current-buffer))))
 
 ;;;; Conversion Functions
 
-(defun doc-view-file-name-to-directory-name (file)
-  "Return the directory where the png files of FILE should be saved.
+(defun doc-view-reconvert-doc (&rest args)
+  "Reconvert the current document.
+Should be invoked when the cached images aren't up-to-date."
+  (interactive)
+  (let ((inhibit-read-only t)
+	(doc doc-view-current-doc))
+    (doc-view-kill-proc)
+    ;; Clear the old cached files
+    (when (file-exists-p (doc-view-current-cache-dir))
+      (dired-delete-file (doc-view-current-cache-dir) 'always))
+    (doc-view-kill-proc-and-buffer)
+    (find-file doc)))
 
-It'a a subdirectory of `doc-view-cache-directory'."
+(defun doc-view-current-cache-dir ()
+  "Return the directory where the png files of the current doc should be saved.
+It's a subdirectory of `doc-view-cache-directory'."
   (if doc-view-current-cache-dir
       doc-view-current-cache-dir
-    (file-name-as-directory
-     (concat (file-name-as-directory doc-view-cache-directory)
-	     (with-temp-buffer
-	       (insert-file-contents-literally file)
-	       (md5 (current-buffer)))))))
+    (setq doc-view-current-cache-dir
+	  (file-name-as-directory
+	   (concat (file-name-as-directory doc-view-cache-directory)
+		   (let ((doc doc-view-current-doc))
+		     (with-temp-buffer
+		       (insert-file-contents-literally doc)
+		       (md5 (current-buffer)))))))))
 
 (defun doc-view-dvi->pdf-sentinel (proc event)
   "If DVI->PDF conversion was successful, convert the PDF to PNG now."
   (if (not (string-match "finished" event))
       (message "DocView: dvi->pdf process changed status to %s." event)
     (set-buffer (process-get proc 'buffer))
-    (setq doc-view-current-converter-process nil)
-    (message "DocView: finished conversion from DVI to PDF!")
+    (setq doc-view-current-converter-process nil
+	  mode-line-process nil)
     ;; Now go on converting this PDF to a set of PNG files.
     (let* ((pdf (process-get proc 'pdf-file))
-	   (png (concat (doc-view-file-name-to-directory-name
-			 doc-view-current-doc)
+	   (png (concat (doc-view-current-cache-dir)
 			"page-%d.png")))
       (doc-view-pdf/ps->png pdf png))))
 
 (defun doc-view-dvi->pdf (dvi pdf)
   "Convert DVI to PDF asynchrounously."
-  (message "DocView: converting DVI to PDF now!")
   (setq doc-view-current-converter-process
-	(start-process "doc-view-dvi->pdf" doc-view-conversion-buffer
+	(start-process "dvi->pdf" doc-view-conversion-buffer
 		       doc-view-dvipdfm-program
-		       "-o" pdf dvi))
+		       "-o" pdf dvi)
+	mode-line-process (list (format ":%s" doc-view-current-converter-process)))
   (set-process-sentinel doc-view-current-converter-process
 			'doc-view-dvi->pdf-sentinel)
   (process-put doc-view-current-converter-process 'buffer   (current-buffer))
@@ -373,24 +420,24 @@
   (if (not (string-match "finished" event))
       (message "DocView: converter process changed status to %s." event)
     (set-buffer (process-get proc 'buffer))
-    (setq doc-view-current-converter-process nil)
+    (setq doc-view-current-converter-process nil
+	  mode-line-process nil)
     (when doc-view-current-timer
       (cancel-timer doc-view-current-timer)
       (setq doc-view-current-timer nil))
-    (message "DocView: finished conversion from PDF/PS to PNG!")
     ;; Yippie, finished.  Update the display!
     (doc-view-display doc-view-current-doc)))
 
 (defun doc-view-pdf/ps->png (pdf-ps png)
   "Convert PDF-PS to PNG asynchrounously."
-  (message "DocView: converting PDF or PS to PNG now!")
   (setq doc-view-current-converter-process
 	(apply 'start-process
-	       (append (list "doc-view-pdf/ps->png" doc-view-conversion-buffer
+	       (append (list "pdf/ps->png" doc-view-conversion-buffer
 			     doc-view-ghostscript-program)
 		       doc-view-ghostscript-options
 		       (list (concat "-sOutputFile=" png))
-		       (list pdf-ps))))
+		       (list pdf-ps)))
+	mode-line-process (list (format ":%s" doc-view-current-converter-process)))
   (process-put doc-view-current-converter-process
 	       'buffer (current-buffer))
   (set-process-sentinel doc-view-current-converter-process
@@ -398,7 +445,7 @@
   (when doc-view-conversion-refresh-interval
     (setq doc-view-current-timer
 	  (run-at-time "1 secs" doc-view-conversion-refresh-interval
-		       'doc-view-display
+		       'doc-view-display-maybe
 		       doc-view-current-doc))))
 
 (defun doc-view-pdf->txt-sentinel (proc event)
@@ -407,8 +454,8 @@
     (let ((current-buffer (current-buffer))
 	  (proc-buffer    (process-get proc 'buffer)))
       (set-buffer proc-buffer)
-      (setq doc-view-current-converter-process nil)
-      (message "DocView: finished conversion from PDF to TXT!")
+      (setq doc-view-current-converter-process nil
+	    mode-line-process nil)
       ;; If the user looks at the DocView buffer where the conversion was
       ;; performed, search anew.  This time it will be queried for a regexp.
       (when (eq current-buffer proc-buffer)
@@ -416,11 +463,11 @@
 
 (defun doc-view-pdf->txt (pdf txt)
   "Convert PDF to TXT asynchrounously."
-  (message "DocView: converting PDF to TXT now!")
   (setq doc-view-current-converter-process
-	(start-process "doc-view-pdf->txt" doc-view-conversion-buffer
+	(start-process "pdf->txt" doc-view-conversion-buffer
 		       doc-view-pdftotext-program "-raw"
-		       pdf txt))
+		       pdf txt)
+	mode-line-process (list (format ":%s" doc-view-current-converter-process)))
   (set-process-sentinel doc-view-current-converter-process
 			'doc-view-pdf->txt-sentinel)
   (process-put doc-view-current-converter-process 'buffer (current-buffer)))
@@ -429,65 +476,45 @@
   (if (not (string-match "finished" event))
       (message "DocView: converter process changed status to %s." event)
     (set-buffer (process-get proc 'buffer))
-    (setq doc-view-current-converter-process nil)
-    (message "DocView: finished conversion from PS to PDF!")
+    (setq doc-view-current-converter-process nil
+	  mode-line-process nil)
     ;; Now we can transform to plain text.
     (doc-view-pdf->txt (process-get proc 'pdf-file)
-		       (concat (doc-view-file-name-to-directory-name
-				doc-view-current-doc)
+		       (concat (doc-view-current-cache-dir)
 			       "doc.txt"))))
 
 (defun doc-view-ps->pdf (ps pdf)
   "Convert PS to PDF asynchronously."
-  (message "DocView: converting PS to PDF now!")
   (setq doc-view-current-converter-process
-	(start-process "doc-view-ps->pdf" doc-view-conversion-buffer
+	(start-process "ps->pdf" doc-view-conversion-buffer
 		       doc-view-ps2pdf-program
-		       ps pdf))
+		       ps pdf
+		       ;; Avoid security problems when rendering files from
+		       ;; untrusted sources.
+		       "-dSAFER")
+	mode-line-process (list (format ":%s" doc-view-current-converter-process)))
   (set-process-sentinel doc-view-current-converter-process
 			'doc-view-ps->pdf-sentinel)
   (process-put doc-view-current-converter-process 'buffer   (current-buffer))
   (process-put doc-view-current-converter-process 'pdf-file pdf))
 
-(defun doc-view-convert-doc (doc)
-  "Convert DOC to a set of png files, one file per page.
-
-Those files are saved in the directory given by
-`doc-view-file-name-to-directory-name'."
+(defun doc-view-convert-current-doc ()
+  "Convert `doc-view-current-doc' to a set of png files, one file per page.
+Those files are saved in the directory given by the function
+`doc-view-current-cache-dir'."
   (clear-image-cache)
-  (let* ((dir (doc-view-file-name-to-directory-name doc))
-	 (png-file (concat (file-name-as-directory dir) "page-%d.png")))
-    (when (file-exists-p dir)
-      (dired-delete-file dir 'always))
-    (make-directory dir t)
-    (if (not (string= (file-name-extension doc) "dvi"))
+  (let ((png-file (concat (doc-view-current-cache-dir)
+			  "page-%d.png")))
+    (make-directory doc-view-current-cache-dir t)
+    (if (not (string= (file-name-extension doc-view-current-doc) "dvi"))
 	;; Convert to PNG images.
-	(doc-view-pdf/ps->png doc png-file)
-      ;; DVI files have to be converted to PDF before GhostScript can process
+	(doc-view-pdf/ps->png doc-view-current-doc png-file)
+      ;; DVI files have to be converted to PDF before Ghostscript can process
       ;; it.
-      (doc-view-dvi->pdf doc
-			 (concat (file-name-as-directory dir)
+      (doc-view-dvi->pdf doc-view-current-doc
+			 (concat (file-name-as-directory doc-view-current-cache-dir)
 				 "doc.pdf")))))
 
-;;;; DocView Mode
-
-(define-derived-mode doc-view-mode nil "DocView"
-  "Major mode in DocView buffers.
-
-\\{doc-view-mode-map}"
-  :group 'doc-view
-  (setq buffer-read-only t)
-  (make-local-variable 'doc-view-current-files)
-  (make-local-variable 'doc-view-current-doc)
-  (make-local-variable 'doc-view-current-image)
-  (make-local-variable 'doc-view-current-page)
-  (make-local-variable 'doc-view-current-converter-process)
-  (make-local-variable 'doc-view-current-timer)
-  (make-local-variable 'doc-view-current-slice)
-  (make-local-variable 'doc-view-current-cache-dir)
-  (make-local-variable 'doc-view-current-info)
-  (make-local-variable 'doc-view-current-search-matches))
-
 ;;;; Slicing
 
 (defun doc-view-set-slice (x y width height)
@@ -555,19 +582,22 @@
 	nil
       (string< a b))))
 
+(defun doc-view-display-maybe (doc)
+  "Call `doc-view-display' iff we're in the image display."
+  (when (eq doc-view-current-display 'image)
+    (doc-view-display doc)))
+
 (defun doc-view-display (doc)
   "Start viewing the document DOC."
-  (let ((dir (doc-view-file-name-to-directory-name doc)))
-    (set-buffer (format "*DocView: %s*" doc))
-    (setq doc-view-current-files
-	  (sort (directory-files dir t "page-[0-9]+\\.png" t)
-		'doc-view-sort))
-    (when (> (length doc-view-current-files) 0)
-      (doc-view-goto-page doc-view-current-page))))
+  (set-buffer (get-file-buffer doc))
+  (setq doc-view-current-files
+	(sort (directory-files (doc-view-current-cache-dir) t
+			       "page-[0-9]+\\.png" t)
+	      'doc-view-sort))
+  (when (> (length doc-view-current-files) 0)
+    (doc-view-goto-page doc-view-current-page)))
 
 (defun doc-view-buffer-message ()
-  (setq inhibit-read-only t)
-  (erase-buffer)
   (insert (propertize "Welcome to DocView!" 'face 'bold)
 	  "\n"
 	  "
@@ -580,12 +610,58 @@
 
 `q' : Bury this buffer.  Conversion will go on in background.
 `k' : Kill the conversion process and this buffer.\n")
-  (setq inhibit-read-only nil))
+  (set-buffer-modified-p nil))
 
 (defun doc-view-show-tooltip ()
   (interactive)
   (tooltip-show doc-view-current-info))
 
+;;;;; Toggle between text and image display
+
+(defun doc-view-toggle-display ()
+  "Start or stop displaying a document file as a set of images.
+This command toggles between showing the text of the document
+file and showing the document as a set of images."
+  (interactive)
+  (if (get-text-property (point-min) 'display)
+      ;; Switch to text display
+      (let ((inhibit-read-only t))
+	(erase-buffer)
+	(insert-file-contents doc-view-current-doc)
+	(use-local-map doc-view-mode-text-map)
+	(setq mode-name "DocView[text]"
+	      doc-view-current-display 'text)
+	(if (called-interactively-p)
+	    (message "Repeat this command to go back to displaying the file as images")))
+    ;; Switch to image display
+    (let ((inhibit-read-only t))
+      (erase-buffer)
+      (doc-view-buffer-message)
+      (setq doc-view-current-page (or doc-view-current-page 1))
+      (if (file-exists-p (doc-view-current-cache-dir))
+	  (progn
+	    (message "DocView: using cached files!")
+	    (doc-view-display doc-view-current-doc))
+	(doc-view-convert-current-doc))
+      (use-local-map doc-view-mode-map)
+      (setq mode-name (format "DocView")
+	    doc-view-current-display 'image)
+      (if (called-interactively-p)
+	  (message "Repeat this command to go back to displaying the file as text"))))
+  (set-buffer-modified-p nil))
+
+;;;;; Leave doc-view-mode and open the file for edit
+
+(defun doc-view-edit-doc ()
+  "Leave `doc-view-mode' and open the current doc with an appropriate editing mode."
+  (interactive)
+  (let ((filename doc-view-current-doc)
+	(auto-mode-alist (append '(("\\.[eE]?[pP][sS]\\'" . ps-mode)
+				   ("\\.\\(pdf\\|PDF\\|dvi\\|DVI\\)$" . fundamental-mode))
+				 auto-mode-alist)))
+    (kill-buffer (current-buffer))
+    (find-file filename)))
+
 ;;;; Searching
 
 (defun doc-view-search-internal (regexp file)
@@ -636,8 +712,7 @@
   (interactive)
   ;; New search, so forget the old results.
   (setq doc-view-current-search-matches nil)
-  (let ((txt (concat (doc-view-file-name-to-directory-name
-		      doc-view-current-doc)
+  (let ((txt (concat (doc-view-current-cache-dir)
 		     "doc.txt")))
     (if (file-readable-p txt)
 	(progn
@@ -660,14 +735,12 @@
 	    ;; Doc is a PS, so convert it to PDF (which will be converted to
 	    ;; TXT thereafter).
 	    (doc-view-ps->pdf doc-view-current-doc
-			      (concat (doc-view-file-name-to-directory-name
-				       doc-view-current-doc)
+			      (concat (doc-view-current-cache-dir)
 				      "doc.pdf")))
 	   ((string= ext "dvi")
 	    ;; Doc is a DVI.  This means that a doc.pdf already exists in its
 	    ;; cache subdirectory.
-	    (doc-view-pdf->txt (concat (doc-view-file-name-to-directory-name
-					doc-view-current-doc)
+	    (doc-view-pdf->txt (concat (doc-view-current-cache-dir)
 				       "doc.pdf")
 			       txt))
 	   (t (error "DocView doesn't know what to do"))))))))
@@ -698,52 +771,42 @@
 	     (y-or-n-p "No more matches before current page.  Wrap to last match? "))
 	(doc-view-goto-page (caar (last doc-view-current-search-matches)))))))
 
-;;;; User Interface Commands
+;;;; User interface commands and the mode
+
+(put 'doc-view-mode 'mode-class 'special)
 
 ;;;###autoload
-(defun doc-view (no-cache &optional file)
-  "Convert FILE to png and start viewing it.
-If no FILE is given, query for on.
-If this FILE is still in the cache, don't convert and use the
-existing page files.  With prefix arg NO-CACHE, don't use the
-cached files and convert anew."
-  (interactive "P")
-  (if (not (and (image-type-available-p 'png)
-		(display-images-p)))
-      (message "DocView: your emacs or display doesn't support png images.")
-    (let* ((doc (or file
-		    (expand-file-name
-		     (let ((completion-ignored-extensions
-			    ;; Don't hide files doc-view can display
-			    (remove-if (lambda (str)
-					 (string-match "\\.\\(ps\\|pdf\\|dvi\\)$"
-						       str))
-				       completion-ignored-extensions)))
-		       (read-file-name "File: " nil nil t)))))
-	   (buffer (get-buffer-create (format "*DocView: %s*" doc)))
-	   (dir (doc-view-file-name-to-directory-name doc)))
-      (switch-to-buffer buffer)
-      (doc-view-buffer-message)
-      (doc-view-mode)
-      (setq doc-view-current-doc doc)
-      (setq doc-view-current-page 1)
-      (if (not (and (file-exists-p dir)
-		    (not no-cache)))
-	  (progn
-	    (setq doc-view-current-cache-dir nil)
-	    (doc-view-convert-doc doc-view-current-doc))
-	(message "DocView: using cached files!")
-	(doc-view-display doc-view-current-doc)))))
-
-(defun doc-view-dired (no-cache)
-  "View the current dired file with doc-view.
-NO-CACHE is the same as in `doc-view'.
-
-You might want to bind this command to a dired key, e.g.
-
-    (define-key dired-mode-map (kbd \"C-c d\") 'doc-view-dired)"
-  (interactive "P")
-  (doc-view no-cache (dired-get-file-for-visit)))
+(define-derived-mode doc-view-mode nil "DocView"
+  "Major mode in DocView buffers.
+You can use \\<doc-view-mode-map>\\[doc-view-toggle-display] to
+toggle between display as a set of images and display as text."
+  :group 'doc-view
+  (make-local-variable 'doc-view-current-files)
+  (make-local-variable 'doc-view-current-doc)
+  (make-local-variable 'doc-view-current-image)
+  (make-local-variable 'doc-view-current-page)
+  (make-local-variable 'doc-view-current-converter-process)
+  (make-local-variable 'doc-view-current-timer)
+  (make-local-variable 'doc-view-current-slice)
+  (make-local-variable 'doc-view-current-cache-dir)
+  (make-local-variable 'doc-view-current-info)
+  (make-local-variable 'doc-view-current-search-matches)
+  (setq doc-view-current-doc (buffer-file-name))
+  (insert-file-contents doc-view-current-doc)
+  (use-local-map doc-view-mode-text-map)
+  (setq mode-name "DocView[text]"
+	doc-view-current-display 'text
+	buffer-read-only t
+	revert-buffer-function 'doc-view-reconvert-doc)
+  ;; Switch to image display if possible
+  (if (and (display-images-p)
+	   (image-type-available-p 'png)
+	   (not (get-text-property (point-min) 'display)))
+      (doc-view-toggle-display))
+  (message
+   "%s"
+   (substitute-command-keys
+    "Type \\[doc-view-toggle-display] to toggle between image and text display.")))
 
 (defun doc-view-clear-cache ()
   "Delete the whole cache (`doc-view-cache-directory')."
--- a/lisp/emacs-lisp/advice.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/emacs-lisp/advice.el	Fri Oct 19 00:00:21 2007 +0000
@@ -2013,7 +2013,10 @@
 (if (not (get 'ad-do-advised-functions 'lisp-indent-hook))
     (put 'ad-do-advised-functions 'lisp-indent-hook 1))
 
-(defmacro ad-get-advice-info (function)
+(defun ad-get-advice-info (function)
+  (get function 'ad-advice-info))
+
+(defmacro ad-get-advice-info-macro (function)
   `(get ,function 'ad-advice-info))
 
 (defmacro ad-set-advice-info (function advice-info)
@@ -2025,7 +2028,7 @@
 (defmacro ad-is-advised (function)
   "Return non-nil if FUNCTION has any advice info associated with it.
 This does not mean that the advice is also active."
-  (list 'ad-get-advice-info function))
+  (list 'ad-get-advice-info-macro function))
 
 (defun ad-initialize-advice-info (function)
   "Initialize the advice info for FUNCTION.
@@ -2035,16 +2038,16 @@
 
 (defmacro ad-get-advice-info-field (function field)
   "Retrieve the value of the advice info FIELD of FUNCTION."
-  `(cdr (assq ,field (ad-get-advice-info ,function))))
+  `(cdr (assq ,field (ad-get-advice-info-macro ,function))))
 
 (defun ad-set-advice-info-field (function field value)
   "Destructively modify VALUE of the advice info FIELD of FUNCTION."
   (and (ad-is-advised function)
-       (cond ((assq field (ad-get-advice-info function))
+       (cond ((assq field (ad-get-advice-info-macro function))
 	      ;; A field with that name is already present:
-              (rplacd (assq field (ad-get-advice-info function)) value))
+              (rplacd (assq field (ad-get-advice-info-macro function)) value))
 	     (t;; otherwise, create a new field with that name:
-	      (nconc (ad-get-advice-info function)
+	      (nconc (ad-get-advice-info-macro function)
 		     (list (cons field value)))))))
 
 ;; Don't make this a macro so we can use it as a predicate:
--- a/lisp/emacs-lisp/find-func.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/emacs-lisp/find-func.el	Fri Oct 19 00:00:21 2007 +0000
@@ -46,8 +46,6 @@
 
 ;;; Code:
 
-(require 'loadhist)
-
 ;;; User variables:
 
 (defgroup find-function nil
--- a/lisp/emerge.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/emerge.el	Fri Oct 19 00:00:21 2007 +0000
@@ -633,7 +633,7 @@
 	   (if output-file
 	       (concat "Output to file: " output-file)
 	     (concat "Output to buffer: " (buffer-name merge-buffer))))
-     (insert-buffer emerge-A-buffer)
+     (save-excursion (insert-buffer-substring emerge-A-buffer))
      (emerge-set-keys)
      (setq emerge-difference-list (emerge-make-diff-list file-A file-B))
      (setq emerge-number-of-differences (length emerge-difference-list))
@@ -712,7 +712,7 @@
   (emerge-eval-in-buffer
    emerge-diff-error-buffer
    (erase-buffer)
-   (insert-buffer emerge-diff-buffer)
+   (save-excursion (insert-buffer-substring emerge-diff-buffer))
    (delete-matching-lines ok-regexp)))
 
 ;;; Top-level and setup functions for three-file mode.
@@ -802,7 +802,7 @@
 	   (if output-file
 	       (concat "Output to file: " output-file)
 	     (concat "Output to buffer: " (buffer-name merge-buffer))))
-     (insert-buffer emerge-A-buffer)
+     (save-excursion (insert-buffer-substring emerge-A-buffer))
      (emerge-set-keys)
      (setq emerge-difference-list
 	   (emerge-make-diff3-list file-A file-B file-ancestor))
--- a/lisp/eshell/esh-cmd.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/eshell/esh-cmd.el	Fri Oct 19 00:00:21 2007 +0000
@@ -204,7 +204,7 @@
   :type 'hook
   :group 'eshell-cmd)
 
-(defcustom eshell-complex-commands nil
+(defcustom eshell-complex-commands '("ls")
   "*A list of commands names or functions, that determine complexity.
 That is, if a command is defined by a function named eshell/NAME,
 and NAME is part of this list, it is invoked as a complex command.
--- a/lisp/faces.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/faces.el	Fri Oct 19 00:00:21 2007 +0000
@@ -1947,8 +1947,10 @@
 	  (modify-frame-parameters frame '((interprogram-cut-function . nil)))
 	  (modify-frame-parameters frame '((interprogram-paste-function . nil)))
 
-	  (set-locale-environment nil frame)
-	  (tty-run-terminal-initialization frame)
+          (unless (terminal-parameter frame 'terminal-initted)
+            (set-terminal-parameter frame 'terminal-initted t)
+            (set-locale-environment nil frame)
+            (tty-run-terminal-initialization frame))
 	  (frame-set-background-mode frame)
 	  (face-set-after-frame-default frame)
 	  (setq success t))
@@ -1981,10 +1983,7 @@
   ;; Load library for our terminal type.
   ;; User init file can set term-file-prefix to nil to prevent this.
   (with-selected-frame frame
-    (unless (or (null term-file-prefix)
-		;; Don't reinitialize the terminal each time a new
-		;; frame is opened on it.
-		(terminal-parameter frame 'terminal-initted))
+    (unless (null term-file-prefix)
       (let* (term-init-func)
 	;; First, load the terminal initialization file, if it is
 	;; available and it hasn't been loaded already.
--- a/lisp/files.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/files.el	Fri Oct 19 00:00:21 2007 +0000
@@ -2060,6 +2060,7 @@
      ("\\.\\(diffs?\\|patch\\|rej\\)\\'" . diff-mode)
      ("\\.\\(dif\\|pat\\)\\'" . diff-mode) ; for MSDOG
      ("\\.[eE]?[pP][sS]\\'" . ps-mode)
+     ("\\.\\(?:PDF\\|DVI\\|pdf\\|dvi\\)" . doc-view-mode)
      ("configure\\.\\(ac\\|in\\)\\'" . autoconf-mode)
      ("BROWSE\\'" . ebrowse-tree-mode)
      ("\\.ebrowse\\'" . ebrowse-tree-mode)
--- a/lisp/filesets.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/filesets.el	Fri Oct 19 00:00:21 2007 +0000
@@ -158,7 +158,7 @@
 	(setq rv (append rv (list elt)))))))
 
 (defun filesets-ormap (fsom-pred lst)
-  "Return the tail of FSOM-LST for the head of which FSOM-PRED is non-nil."
+  "Return the tail of LST for the head of which FSOM-PRED is non-nil."
   (let ((fsom-lst lst)
 	(fsom-rv nil))
     (while (and (not (null fsom-lst))
@@ -535,7 +535,7 @@
   :group 'filesets)
 
 (defcustom filesets-sort-case-sensitive-flag t
-  "Non-nil means sorting of the filesete menu is case sensitive."
+  "Non-nil means sorting of the filesets menu is case sensitive."
   :set (function filesets-set-default)
   :type 'boolean
   :group 'filesets)
@@ -1091,10 +1091,7 @@
   "Return a sorted copy of LST, LST being a list of strings.
 If `filesets-sort-menu-flag' is nil, return LST itself.
 
-ACCESS-FN ... function to get the string value of LST's elements.
-
-If SIMPLY-DO-IT is non-nil, the list is sorted regardless of
-`filesets-sort-menu-flag'."
+ACCESS-FN ... function to get the string value of LST's elements."
   (if filesets-sort-menu-flag
       (let* ((fni (or access-fn
 		      (function identity)))
@@ -1363,7 +1360,7 @@
     (find-file file)))
 
 (defun filesets-find-or-display-file (&optional file viewer)
-  "Visit FILE using an external viewer or open it in an Emacs buffer."
+  "Visit FILE using an external VIEWER or open it in an Emacs buffer."
   (interactive)
   (let* ((file (or file
 		   (read-file-name "Find file: " nil nil viewer)))
@@ -1414,24 +1411,24 @@
     something)))
 
 (defun filesets-data-get-name (entry)
-  "Access to `filesets-data'.  Get the entry's name."
+  "Access to `filesets-data'.  Get the ENTRY's name."
   (car entry))
 
 (defun filesets-data-get-data (entry)
-  "Access to `filesets-data'.  Get the entry's data section."
+  "Access to `filesets-data'.  Get the ENTRY's data section."
   (cdr entry))
 
 (defun filesets-alist-get (alist key &optional default carp)
   "Get KEY's value in the association list ALIST.
 Return DEFAULT if not found.  Return (car VALUE) if CARP is non-nil."
-  (let* ((elt (assoc key alist)))
+  (let ((elt (assoc key alist)))
     (cond
-     (elt
-      (if carp
-	  (cadr elt)
-	(cdr elt)))
-     (default default)
-     (t nil))))
+      (elt
+       (if carp
+	   (cadr elt)
+	 (cdr elt)))
+      (default default)
+      (t nil))))
 
 (defun filesets-data-get (entry key &optional default carp)
   "Extract the value for KEY in the data part of fileset ENTRY.
@@ -1439,7 +1436,7 @@
   (filesets-alist-get (filesets-data-get-data entry) key default carp))
 
 (defun filesets-data-set (entry key value)
-  "Set the value for KEY in the data part of fileset ENTRY."
+  "Set the VALUE for KEY in the data part of fileset ENTRY."
   (let* ((alist (filesets-data-get-data entry))
 	 (elt (assoc key alist)))
     (if elt
@@ -1666,9 +1663,9 @@
 	       filesets-commands)))
 
 
-;;; sampe commands
+;;; sample commands
 (defun filesets-cmd-query-replace-getargs ()
-  "Get arguments for `filesets-cmd-query-replace'."
+  "Get arguments for `query-replace' and `query-replace-regexp'."
   (let* ((from-string (read-string "Filesets query replace: "
 				   ""
 				   'query-replace-history))
@@ -1875,7 +1872,7 @@
   (browse-url filesets-homepage))
 
 (defun filesets-remake-shortcut (count submenu)
-  "Remake a submenus shortcut when wrapping long menus."
+  "Remake a submenu's shortcut when wrapping long menus."
   (let* ((name (concat (filesets-get-shortcut count)
 		       (substring (elt submenu 0) 2))))
     (if (listp submenu)
@@ -2032,7 +2029,7 @@
 	  (lax-plist-put filesets-ingroup-cache emaster this))))
 
 (defun filesets-ingroup-collect-files (fs &optional remdupl-flag master depth)
-  "Helper function for `filesets-ingroup-collect'. Collect file names."
+  "Helper function for `filesets-ingroup-collect'.  Collect file names."
   (let* ((master       (or master
 			   (filesets-entry-get-master fs)))
 	 (remdupl-flag (or remdupl-flag
@@ -2146,7 +2143,7 @@
 			  `([,nm (filesets-file-open nil ',master ',fsn)])))))))))
 
 (defun filesets-ingroup-collect (fs remdupl-flag master)
-  "Collect names of included files & build submenu."
+  "Collect names of included files and build submenu."
   (filesets-ingroup-cache-put master nil)
   (filesets-message 2 "Filesets: parsing %S" master)
   (filesets-ingroup-collect-build-menu
--- a/lisp/gnus/ChangeLog	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/gnus/ChangeLog	Fri Oct 19 00:00:21 2007 +0000
@@ -1,3 +1,15 @@
+2007-10-15  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* gnus-util.el (gnus-string<): New function.
+
+	* gnus-sum.el (gnus-article-sort-by-author)
+	(gnus-article-sort-by-subject): Use it.
+
+2007-10-15  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* gnus-win.el (gnus-configure-windows): Focus on the frame for which
+	the frame-focus tag is set in gnus-buffer-configuration.
+
 2007-10-04  Juanma Barranquero  <lekktu@gmail.com>
 
 	* sieve-manage.el (sieve-manage-interactive-login): Doc fix.
--- a/lisp/gnus/gnus-sum.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/gnus/gnus-sum.el	Fri Oct 19 00:00:21 2007 +0000
@@ -4674,7 +4674,7 @@
 
 (defsubst gnus-article-sort-by-author (h1 h2)
   "Sort articles by root author."
-  (string-lessp
+  (gnus-string<
    (let ((extract (funcall
 		   gnus-extract-address-components
 		   (mail-header-from h1))))
@@ -4691,7 +4691,7 @@
 
 (defsubst gnus-article-sort-by-subject (h1 h2)
   "Sort articles by root subject."
-  (string-lessp
+  (gnus-string<
    (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
    (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
 
--- a/lisp/gnus/gnus-util.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/gnus/gnus-util.el	Fri Oct 19 00:00:21 2007 +0000
@@ -290,6 +290,15 @@
   (not (or (string< s1 s2)
 	   (string= s1 s2))))
 
+(defun gnus-string< (s1 s2)
+  "Return t if first arg string is less than second in lexicographic order.
+Case is significant if and only if `case-fold-search' is nil.
+Symbols are also allowed; their print names are used instead."
+  (if case-fold-search
+      (string-lessp (downcase (if (symbolp s1) (symbol-name s1) s1))
+		    (downcase (if (symbolp s2) (symbol-name s2) s2)))
+    (string-lessp s1 s2)))
+
 ;;; Time functions.
 
 (defun gnus-file-newer-than (file date)
--- a/lisp/gnus/gnus-win.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/gnus/gnus-win.el	Fri Oct 19 00:00:21 2007 +0000
@@ -471,7 +471,8 @@
 	  (gnus-configure-frame split)
 	  (run-hooks 'gnus-configure-windows-hook)
 	  (when gnus-window-frame-focus
-	    (select-frame (window-frame gnus-window-frame-focus))))))))
+	    (gnus-select-frame-set-input-focus
+	     (window-frame gnus-window-frame-focus))))))))
 
 (defun gnus-delete-windows-in-gnusey-frames ()
   "Do a `delete-other-windows' in all frames that have Gnus windows."
--- a/lisp/help-fns.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/help-fns.el	Fri Oct 19 00:00:21 2007 +0000
@@ -239,7 +239,7 @@
 				   ".elc"))
 				 load-path))
 	 (str (if (and elc-file (file-readable-p elc-file))
-		  (with-temp-buffer 
+		  (with-temp-buffer
 		    (insert-file-contents-literally elc-file nil 0 256)
 		    (buffer-string))))
 	 (src-file (and str
--- a/lisp/ibuf-ext.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/ibuf-ext.el	Fri Oct 19 00:00:21 2007 +0000
@@ -180,8 +180,8 @@
 
 See also the variables `ibuffer-filter-groups',
 `ibuffer-filtering-qualifiers', `ibuffer-filtering-alist', and the
-functions `ibuffer-switch-to-saved-filter-group',
-`ibuffer-save-filter-group'."
+functions `ibuffer-switch-to-saved-filter-groups',
+`ibuffer-save-filter-groups'."
   :type '(repeat sexp)
   :group 'ibuffer)
 
--- a/lisp/indent.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/indent.el	Fri Oct 19 00:00:21 2007 +0000
@@ -86,10 +86,10 @@
 indent the region.
 The function actually called to indent the line is determined by the value of
 `indent-line-function'."
-  (interactive "P")
+  (interactive "p")
   (cond
    ;; The region is active, indent it.
-   ((and transient-mark-mode mark-active
+   ((and arg transient-mark-mode mark-active
 	 (not (eq (region-beginning) (region-end))))
     (indent-region (region-beginning) (region-end)))
    ((or ;; indent-to-left-margin is only meant for indenting,
--- a/lisp/international/encoded-kb.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/international/encoded-kb.el	Fri Oct 19 00:00:21 2007 +0000
@@ -338,38 +338,63 @@
     (when frame
       (with-selected-frame frame
 	;; Remove any previous encoded-kb keymap from input-decode-map.
-	(let ((m input-decode-map))
-	  (if (equal (keymap-prompt m) "encoded-kb")
-	      (setq input-decode-map (keymap-parent m))
-	    (while (keymap-parent m)
-	      (if (equal (keymap-prompt (keymap-parent m)) "encoded-kb")
-		  (set-keymap-parent m (keymap-parent (keymap-parent m))))
-	      (setq m (keymap-parent m)))))
+	(let ((m input-decode-map)
+              (child nil))
+          (while (keymapp m)
+            (if (not (equal (keymap-prompt m) "encoded-kb"))
+                (progn
+                  (setq child m)
+                  (setq m (keymap-parent m)))
+              ;; We've found an encoded-kb map, but maybe the prompt we get
+              ;; is really inherited from the encoded-kb map.
+              (let (mp)
+                (while (and (keymapp (setq mp (keymap-parent m)))
+                            (equal (keymap-prompt mp) "encoded-kb"))
+                  (setq child m)
+                  (setq m mp))
+                ;; (assert (equal (keymap-prompt m) "encoded-kb"))
+                ;; (assert (eq mp (keymap-parent m)))
+                ;; (assert (not (and (keymapp mp)
+                ;;                   (equal (keymap-prompt mp) "encoded-kb"))))
+                ;; (assert (eq m (if child
+                ;;                   (keymap-parent child) input-decode-map)))
+                ;; We can finally do the actual removal.
+                (if child
+                    (set-keymap-parent child mp)
+                  (setq input-decode-map mp))
+                (setq m mp))))))
 
-	(if (keyboard-coding-system)
-	    ;; We are turning on Encoded-kbd mode.
-	    (let ((coding (keyboard-coding-system))
-		  (keymap (make-sparse-keymap "encoded-kb"))
-		  (cim (current-input-mode))
-		  result)
-	      (set-keymap-parent keymap input-decode-map)
-	      (setq input-decode-map keymap)
-	      (unless (terminal-parameter nil 'encoded-kbd-saved-input-meta-mode)
-		(set-terminal-parameter nil 'encoded-kbd-saved-input-mode (nth 2 cim)))
-	      (setq result (and coding (encoded-kbd-setup-keymap keymap coding)))
-	      (if result
-		  (when (and (eq result 8)
-			     (memq (nth 2 cim) '(t nil)))
-		    (set-input-meta-mode 'use-8th-bit))
-		(set-terminal-parameter nil 'encoded-kbd-saved-input-meta-mode nil)
-		(error "Unsupported coding system in Encoded-kbd mode: %S"
-		       coding)))
-	  ;; We are turning off Encoded-kbd mode.
-	  (when (and (terminal-parameter nil 'encoded-kbd-saved-input-meta-mode)
-		     (not (equal (nth 2 (current-input-mode))
-				 (terminal-parameter nil 'encoded-kbd-saved-input-meta-mode))))
-	    (set-input-meta-mode (terminal-parameter nil 'encoded-kbd-saved-input-meta-mode)))
-	  (set-terminal-parameter nil 'saved-input-meta-mode nil))))))
+      (if (keyboard-coding-system)
+          ;; We are turning on Encoded-kbd mode.
+          (let ((coding (keyboard-coding-system))
+                (keymap (make-sparse-keymap "encoded-kb"))
+                (cim (current-input-mode))
+                result)
+            ;; Place `keymap' as the immediate parent of input-decode-map
+            ;; rather than on top, so that later `define-key' on
+            ;; input-decode-map don't end up accidentally changing our
+            ;; part of the keymap, which would lead to bugs when/if we later
+            ;; on remove that part.
+            (set-keymap-parent keymap (keymap-parent input-decode-map))
+            (set-keymap-parent input-decode-map keymap)
+            (unless (terminal-parameter nil 'encoded-kbd-saved-input-meta-mode)
+              (set-terminal-parameter nil 'encoded-kbd-saved-input-mode
+                                      (nth 2 cim)))
+            (setq result (and coding (encoded-kbd-setup-keymap keymap coding)))
+            (if result
+                (when (and (eq result 8)
+                           (memq (nth 2 cim) '(t nil)))
+                  (set-input-meta-mode 'use-8th-bit))
+              (set-terminal-parameter
+               nil 'encoded-kbd-saved-input-meta-mode nil)
+              (error "Unsupported coding system in Encoded-kbd mode: %S"
+                     coding)))
+        ;; We are turning off Encoded-kbd mode.
+        (let ((old (terminal-parameter nil 'encoded-kbd-saved-input-meta-mode)))
+          (when (and old (not (equal (nth 2 (current-input-mode)) old)))
+            (set-input-meta-mode old))
+          (set-terminal-parameter
+           nil 'encoded-kbd-saved-input-meta-mode nil))))))
 
 (provide 'encoded-kb)
 
--- a/lisp/loadhist.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/loadhist.el	Fri Oct 19 00:00:21 2007 +0000
@@ -38,12 +38,11 @@
   "Return the file and list of definitions associated with FEATURE.
 The value is actually the element of `load-history'
 for the file that did (provide FEATURE)."
-   (catch 'foundit
-     (mapc (lambda (x)
-	     (if (member (cons 'provide feature) (cdr x))
-		 (throw 'foundit x)))
-	   load-history)
-     nil))
+  (catch 'foundit
+    (let ((element (cons 'provide feature)))
+      (dolist (x load-history nil)
+	(when (member element (cdr x))
+	  (throw 'foundit x))))))
 
 (defun feature-file (feature)
   "Return the file name from which a given FEATURE was loaded.
@@ -72,32 +71,25 @@
   "Return the list of features provided by FILE as it was loaded.
 FILE can be a file name, or a library name.
 A library name is equivalent to the file name that `load-library' would load."
-  (let ((symbols (file-loadhist-lookup file))
-	provides)
-    (mapc (lambda (x)
-	    (if (and (consp x) (eq (car x) 'provide))
-		(setq provides (cons (cdr x) provides))))
-	  symbols)
-    provides))
+  (let (provides)
+    (dolist (x (file-loadhist-lookup file) provides)
+      (when (eq (car-safe x) 'provide)
+	(push x provides)))))
 
 (defun file-requires (file)
   "Return the list of features required by FILE as it was loaded.
 FILE can be a file name, or a library name.
 A library name is equivalent to the file name that `load-library' would load."
-  (let ((symbols (file-loadhist-lookup file))
-	requires)
-    (mapc (lambda (x)
-	    (if (and (consp x) (eq (car x) 'require))
-		(setq requires (cons (cdr x) requires))))
-	  symbols)
-    requires))
+  (let (requires)
+    (dolist (x (file-loadhist-lookup file) requires)
+      (when (eq (car-safe x) 'require)
+	(push x requires)))))
 
 (defsubst file-set-intersect (p q)
   "Return the set intersection of two lists."
-  (let ((ret nil))
+  (let (ret)
     (dolist (x p ret)
-      (if (memq x q) (setq ret (cons x ret))))
-    ret))
+      (when (memq x q) (push x ret)))))
 
 (defun file-dependents (file)
   "Return the list of loaded libraries that depend on FILE.
@@ -107,9 +99,8 @@
   (let ((provides (file-provides file))
 	(dependents nil))
     (dolist (x load-history dependents)
-      (if (file-set-intersect provides (file-requires (car x)))
-	  (setq dependents (cons (car x) dependents))))
-    dependents))
+      (when (file-set-intersect provides (file-requires (car x)))
+	(push (car x) dependents)))))
 
 (defun read-feature (prompt &optional loaded-p)
   "Read feature name from the minibuffer, prompting with string PROMPT.
@@ -126,15 +117,19 @@
 
 (defvaralias 'loadhist-hook-functions 'unload-feature-special-hooks)
 (defvar unload-feature-special-hooks
-  '(after-change-functions
-    after-insert-file-functions auto-fill-function
-    before-change-functions blink-paren-function
-    buffer-access-fontify-functions command-line-functions
-    comment-indent-function kill-buffer-query-functions
-    kill-emacs-query-functions lisp-indent-function
-    mouse-position-function
+  '(after-change-functions after-insert-file-functions
+    after-make-frame-functions auto-fill-function before-change-functions
+    blink-paren-function buffer-access-fontify-functions command-line-functions
+    comment-indent-function compilation-finish-functions
+    disabled-command-function find-file-not-found-functions
+    font-lock-beginning-of-syntax-function font-lock-fontify-buffer-function
+    font-lock-fontify-region-function font-lock-mark-block-function
+    font-lock-syntactic-face-function font-lock-unfontify-buffer-function
+    font-lock-unfontify-region-function kill-buffer-query-functions
+    kill-emacs-query-functions lisp-indent-function mouse-position-function
     redisplay-end-trigger-functions temp-buffer-show-function
     window-scroll-functions window-size-change-functions
+    write-contents-functions write-file-functions
     write-region-annotate-functions)
   "A list of special hooks from Info node `(elisp)Standard Hooks'.
 
--- a/lisp/longlines.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/longlines.el	Fri Oct 19 00:00:21 2007 +0000
@@ -55,7 +55,11 @@
   "Non-nil means wrapping and filling happen at the edge of the window.
 Otherwise, `fill-column' is used, regardless of the window size.  This
 does not work well when the buffer is displayed in multiple windows
-with differing widths."
+with differing widths.
+
+If the value is an integer, that specifies the distance from the
+right edge of the window at which wrapping occurs.  For any other
+non-nil value, wrapping occurs 2 characters from the right edge."
   :group 'longlines
   :type 'boolean)
 
@@ -117,8 +121,14 @@
 	     'longlines-search-function)
         (add-to-list 'buffer-substring-filters 'longlines-encode-string)
         (when longlines-wrap-follows-window-size
-          (set (make-local-variable 'fill-column)
-               (- (window-width) window-min-width))
+	  (let ((dw (if (and (integerp longlines-wrap-follows-window-size)
+			     (>= longlines-wrap-follows-window-size 0)
+			     (< longlines-wrap-follows-window-size
+				(window-width)))
+			longlines-wrap-follows-window-size
+		      2)))
+	    (set (make-local-variable 'fill-column)
+		 (- (window-width) dw)))
           (add-hook 'window-configuration-change-hook
                     'longlines-window-change-function nil t))
         (let ((buffer-undo-list t)
@@ -415,9 +425,14 @@
 (defun longlines-window-change-function ()
   "Re-wrap the buffer if the window width has changed.
 This is called by `window-configuration-change-hook'."
-  (when (/= fill-column (- (window-width) window-min-width))
-    (setq fill-column (- (window-width) window-min-width))
-    (longlines-wrap-region (point-min) (point-max))))
+  (let ((dw (if (and (integerp longlines-wrap-follows-window-size)
+		     (>= longlines-wrap-follows-window-size 0)
+		     (< longlines-wrap-follows-window-size (window-width)))
+		longlines-wrap-follows-window-size
+	      2)))
+    (when (/= fill-column (- (window-width) dw))
+      (setq fill-column (- (window-width) dw))
+      (longlines-wrap-region (point-min) (point-max)))))
 
 ;; Isearch
 
--- a/lisp/mail/sendmail.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/mail/sendmail.el	Fri Oct 19 00:00:21 2007 +0000
@@ -991,6 +991,19 @@
 	   nil)
 	  (t (error "Invalid value for `mail-from-style'")))))
 
+;; Normally you will not need to modify these options unless you are
+;; using some non-genuine substitute for sendmail which does not
+;; implement each and every option that the original supports.
+;; E.g., ssmtp does not support "-odb", so, if your site uses it,
+;; you will need to modify `sendmail-error-reporting-non-interactive'
+;; in your site-init.el.
+(defvar sendmail-error-reporting-interactive
+  ;; These mean "report errors to terminal" and "deliver interactively"
+  '("-oep" "-odi"))
+(defvar sendmail-error-reporting-non-interactive
+  ;; These mean "report errors by mail" and "deliver in background".
+  '("-oem" "-odb"))
+
 (defun sendmail-send-it ()
   "Send the current mail buffer using the Sendmail package.
 This is a suitable value for `send-mail-function'.  It sends using the
@@ -1135,12 +1148,8 @@
 			      (and mail-alias-file
 				   (list (concat "-oA" mail-alias-file)))
 			      (if mail-interactive
-				  ;; These mean "report errors to terminal"
-				  ;; and "deliver interactively"
-				  '("-oep" "-odi")
-				;; These mean "report errors by mail"
-				;; and "deliver in background".
-				'("-oem" "-odb"))
+                                  sendmail-error-reporting-interactive
+                                  sendmail-error-reporting-non-interactive)
 			      ;; Get the addresses from the message
 			      ;; unless this is a resend.
 			      ;; We must not do that for a resend
--- a/lisp/net/tramp.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/net/tramp.el	Fri Oct 19 00:00:21 2007 +0000
@@ -2092,12 +2092,13 @@
 			  (symbol-value 'rfn-eshadow-overlay))
 		 (funcall (symbol-function 'minibuffer-prompt-end)))))
     (when (file-remote-p (buffer-substring-no-properties end (point-max)))
-      (narrow-to-region
-       (1+ (or (string-match "/" (buffer-string) end) end)) (point-max))
-      (let ((rfn-eshadow-overlay tramp-rfn-eshadow-overlay)
-	    (rfn-eshadow-update-overlay-hook nil))
-	(funcall (symbol-function 'rfn-eshadow-update-overlay)))
-      (widen))))
+      (save-excursion
+	(save-restriction
+	  (narrow-to-region
+	   (1+ (or (string-match "/" (buffer-string) end) end)) (point-max))
+	  (let ((rfn-eshadow-overlay tramp-rfn-eshadow-overlay)
+		(rfn-eshadow-update-overlay-hook nil))
+	    (funcall (symbol-function 'rfn-eshadow-update-overlay))))))))
 
 (when (boundp 'rfn-eshadow-update-overlay-hook)
   (add-hook 'rfn-eshadow-update-overlay-hook
--- a/lisp/progmodes/cc-menus.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/progmodes/cc-menus.el	Fri Oct 19 00:00:21 2007 +0000
@@ -106,7 +106,9 @@
     (nil
      ,(concat
        "^\\<"                                 ; line MUST start with word char
-       "[^()]*"                               ; no parentheses before
+       ;; \n added to prevent overflow in regexp matcher.
+       ;; http://lists.gnu.org/archive/html/emacs-pretest-bug/2007-02/msg00021.html
+       "[^()\n]*"                             ; no parentheses before
        "[^" c-alnum "_:<>~]"                  ; match any non-identifier char
        "\\([" c-alpha "_][" c-alnum "_:<>~]*\\)" ; match function name
        "\\([ \t\n]\\|\\\\\n\\)*("	      ; see above, BUT the arg list
--- a/lisp/progmodes/compile.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/progmodes/compile.el	Fri Oct 19 00:00:21 2007 +0000
@@ -1658,10 +1658,15 @@
     ;;  in the same process and buffer).
     ;; So, recalculate all markers for that file.
     (unless (and (nth 3 loc) (marker-buffer (nth 3 loc))
-                 (equal (nth 4 loc)
-                        (setq timestamp
-                              (with-current-buffer (marker-buffer (nth 3 loc))
-                                (visited-file-modtime)))))
+                 ;; There may be no timestamp info if the loc is a `fake-loc'.
+                 ;; So we skip the time-check here, although we should maybe
+                 ;; change `compilation-fake-loc' to add timestamp info.
+                 (or (null (nth 4 loc))
+                     (equal (nth 4 loc)
+                            (setq timestamp
+                                  (with-current-buffer
+                                      (marker-buffer (nth 3 loc))
+                                    (visited-file-modtime))))))
       (with-current-buffer (compilation-find-file marker (caar (nth 2 loc))
 						  (cadr (car (nth 2 loc))))
 	(save-restriction
@@ -1711,7 +1716,7 @@
   (or (consp file) (setq file (list file)))
   (setq file (compilation-get-file-structure file))
   ;; Between the current call to compilation-fake-loc and the first occurrence
-  ;; of an error message referring to `file', the data is only kept is the
+  ;; of an error message referring to `file', the data is only kept in the
   ;; weak hash-table compilation-locs, so we need to prevent this entry
   ;; in compilation-locs from being GC'd away.  --Stef
   (push file compilation-gcpro)
--- a/lisp/progmodes/delphi.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/progmodes/delphi.el	Fri Oct 19 00:00:21 2007 +0000
@@ -1642,7 +1642,7 @@
   (when delphi-newline-always-indents
     ;; Indent both the (now) previous and current line first.
     (save-excursion
-      (previous-line 1)
+      (forward-line -1)
       (delphi-indent-line))
     (delphi-indent-line)))
 
--- a/lisp/server.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/server.el	Fri Oct 19 00:00:21 2007 +0000
@@ -325,7 +325,10 @@
 
 (defun server-select-display (display)
   ;; If the current frame is on `display' we're all set.
-  (unless (equal (frame-parameter (selected-frame) 'display) display)
+  ;; Similarly if we are unable to open a frames on other displays, there's
+  ;; nothing more we can do.
+  (unless (or (not (fboundp 'make-frame-on-display))
+              (equal (frame-parameter (selected-frame) 'display) display))
     ;; Otherwise, look for an existing frame there and select it.
     (dolist (frame (frame-list))
       (when (equal (frame-parameter frame 'display) display)
@@ -505,11 +508,11 @@
 	  (when server-use-tcp
 	    (let ((auth-key
 		   (loop
-		    ;; The auth key is a 64-byte string of random chars in the
-		    ;; range `!'..`~'.
-		    for i below 64
-		    collect (+ 33 (random 94)) into auth
-		    finally return (concat auth))))
+		      ;; The auth key is a 64-byte string of random chars in the
+		      ;; range `!'..`~'.
+		      for i below 64
+		      collect (+ 33 (random 94)) into auth
+		      finally return (concat auth))))
 	      (process-put server-process :auth-key auth-key)
 	      (with-temp-file server-file
 		(set-buffer-multibyte nil)
@@ -831,8 +834,8 @@
 		 ;; Open X frames on the given display instead of the default.
 		 ((and (equal "-display" arg)
                        (string-match "\\([^ ]*\\) " request))
-		  (setq display (match-string 1 request)
-			request (substring request (match-end 0))))
+                  (setq display (match-string 1 request))
+		  (setq request (substring request (match-end 0))))
 
 		 ;; -window-system:  Open a new X frame.
 		 ((equal "-window-system" arg)
--- a/lisp/simple.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/simple.el	Fri Oct 19 00:00:21 2007 +0000
@@ -1,7 +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 Free Software Foundation, Inc.
+;;   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+;;   Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: internal
@@ -632,7 +633,9 @@
     (newline)
     (save-excursion
       (goto-char pos)
-      (indent-according-to-mode)
+      ;; Usually indent-according-to-mode should "preserve" point, but it is
+      ;; not guaranteed; e.g. indent-to-left-margin doesn't.
+      (save-excursion (indent-according-to-mode))
       (delete-horizontal-space t))
     (indent-according-to-mode)))
 
@@ -2561,6 +2564,11 @@
 string, then the caller of the function \(usually `current-kill')
 should put this string in the kill ring as the latest kill.
 
+This function may also return a list of strings if the window
+system supports multiple selections. The first string will be
+used as the pasted text, but the other will be placed in the
+kill ring for easy access via `yank-pop'.
+
 Note that the function should return a string only if a program other
 than Emacs has provided a string for pasting; if Emacs provided the
 most recent string, the function should return nil.  If it is
@@ -2644,11 +2652,11 @@
 
 (defun current-kill (n &optional do-not-move)
   "Rotate the yanking point by N places, and then return that kill.
-If N is zero, `interprogram-paste-function' is set, and calling it
-returns a string, then that string is added to the front of the
-kill ring and returned as the latest kill.
-If optional arg DO-NOT-MOVE is non-nil, then don't actually move the
-yanking point; just return the Nth kill forward."
+If N is zero, `interprogram-paste-function' is set, and calling it returns a
+string or list of strings, then that string (or list) is added to the front
+of the kill ring and the string (or first string in the list) is returned as
+the latest kill.  If optional arg DO-NOT-MOVE is non-nil, then don't
+actually move the yanking point; just return the Nth kill forward."
   (let ((interprogram-paste (and (= n 0)
 				 interprogram-paste-function
 				 (funcall interprogram-paste-function))))
@@ -2658,8 +2666,10 @@
 	  ;; text to the kill ring, so Emacs doesn't try to own the
 	  ;; selection, with identical text.
 	  (let ((interprogram-cut-function nil))
-	    (kill-new interprogram-paste))
-	  interprogram-paste)
+	    (if (listp interprogram-paste)
+	      (mapc 'kill-new (nreverse interprogram-paste))
+	      (kill-new interprogram-paste)))
+	  (car kill-ring))
       (or kill-ring (error "Kill ring is empty"))
       (let ((ARGth-kill-element
 	     (nthcdr (mod (- n (length kill-ring-yank-pointer))
@@ -4657,6 +4667,8 @@
 				 (point))))))
     (let* ((oldpos (point))
 	   (message-log-max nil)  ; Don't log messages about paren matching.
+	   (atdollar (eq (syntax-class (syntax-after (1- oldpos))) 8))
+	   (isdollar)
 	   (blinkpos
             (save-excursion
               (save-restriction
@@ -4674,20 +4686,28 @@
 	   (matching-paren
             (and blinkpos
                  ;; Not syntax '$'.
-                 (not (eq (syntax-class (syntax-after blinkpos)) 8))
+                 (not (setq isdollar
+                            (eq (syntax-class (syntax-after blinkpos)) 8)))
                  (let ((syntax (syntax-after blinkpos)))
                    (and (consp syntax)
                         (eq (syntax-class syntax) 4)
                         (cdr syntax))))))
       (cond
-       ((not (or (eq matching-paren (char-before oldpos))
+       ;; isdollar is for:
+       ;; http://lists.gnu.org/archive/html/emacs-devel/2007-10/msg00871.html
+       ((not (or (and isdollar blinkpos)
+                 (and atdollar (not blinkpos)) ; see below
+                 (eq matching-paren (char-before oldpos))
                  ;; The cdr might hold a new paren-class info rather than
                  ;; a matching-char info, in which case the two CDRs
                  ;; should match.
                  (eq matching-paren (cdr (syntax-after (1- oldpos))))))
         (message "Mismatched parentheses"))
        ((not blinkpos)
-        (if (not blink-matching-paren-distance)
+        (or blink-matching-paren-distance
+            ;; Don't complain when `$' with no blinkpos, because it
+            ;; could just be the first one typed in the buffer.
+            atdollar
             (message "Unmatched parenthesis")))
        ((pos-visible-in-window-p blinkpos)
         ;; Matching open within window, temporarily move to blinkpos but only
--- a/lisp/term/xterm.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/term/xterm.el	Fri Oct 19 00:00:21 2007 +0000
@@ -27,8 +27,6 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'xt-mouse))
-
 (defvar xterm-function-map
   (let ((map (make-sparse-keymap)))
 
@@ -469,12 +467,8 @@
     ;; This recomputes all the default faces given the colors we've just set up.
     (tty-set-up-initial-frame-faces)
     
-    (when xterm-mouse-mode
-      (turn-on-xterm-mouse-tracking-on-terminal 
-       (frame-terminal (selected-frame))))
-    
     ;; Try to turn on the modifyOtherKeys feature on modern xterms.
-    ;; When it is turned on much more key bindings work: things like
+    ;; When it is turned on many more key bindings work: things like
     ;; C-. C-, etc.
     ;; To do that we need to find out if the current terminal supports
     ;; modifyOtherKeys. At this time only xterm does.
@@ -506,7 +500,9 @@
 	      ;; need to deal with modify-other-keys.
 	      (push (frame-terminal (selected-frame))
 		    xterm-modify-other-keys-terminal-list)
-	      (xterm-turn-on-modify-other-keys)))))))
+	      (xterm-turn-on-modify-other-keys))))))
+
+    (run-hooks 'terminal-init-xterm-hook))
 
 ;; Set up colors, for those versions of xterm that support it.
 (defvar xterm-standard-colors
--- a/lisp/textmodes/artist.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/textmodes/artist.el	Fri Oct 19 00:00:21 2007 +0000
@@ -4383,13 +4383,10 @@
 If N is negative, move cursor down."
   (interactive "p")
   (let ((col (artist-current-column)))
-    (if (not artist-key-is-drawing)
-	(progn
-	  (previous-line n)
-	  (move-to-column col t))
-      (previous-line n)
-      (move-to-column col t)
-      (artist-key-do-continously-common))))
+    (forward-line (- n))
+    (move-to-column col t))
+  (when artist-key-is-drawing
+    (artist-key-do-continously-common)))
 
 
 (defun artist-next-line (&optional n)
@@ -4397,13 +4394,10 @@
 If N is negative, move cursor up."
   (interactive "p")
   (let ((col (artist-current-column)))
-    (if (not artist-key-is-drawing)
-	(progn
-	  (next-line n)
-	  (move-to-column col t))
-      (next-line n)
-      (move-to-column col t)
-      (artist-key-do-continously-common))))
+    (forward-line n)
+    (move-to-column col t))
+  (when artist-key-is-drawing
+    (artist-key-do-continously-common)))
 
 (defun artist-backward-char (&optional n)
   "Move cursor backward optional N chars (default is 1), updating curr shape.
--- a/lisp/textmodes/fill.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/textmodes/fill.el	Fri Oct 19 00:00:21 2007 +0000
@@ -117,8 +117,8 @@
   :group 'fill)
 
 (defcustom adaptive-fill-function nil
-  "*Function to call to choose a fill prefix for a paragraph, or nil.
-nil means the function has not determined the fill prefix."
+  "Function to call to choose a fill prefix for a paragraph, or nil.
+A nil value means the function has not determined the fill prefix."
   :type '(choice (const nil) function)
   :group 'fill)
 
@@ -757,10 +757,10 @@
     (narrow-to-region (minibuffer-prompt-end) (point-max))
     (fill-paragraph arg)))
 
-(defun fill-paragraph (arg)
+(defun fill-paragraph (&optional justify region)
   "Fill paragraph at or after point.
 
-If ARG is non-nil (interactively, with prefix argument), justify as well.
+If JUSTIFY is non-nil (interactively, with prefix argument), justify as well.
 If `sentence-end-double-space' is non-nil, then period followed by one
 space does not end a sentence, so don't break a line there.
 the variable `fill-column' controls the width for filling.
@@ -768,64 +768,73 @@
 If `fill-paragraph-function' is non-nil, we call it (passing our
 argument to it), and if it returns non-nil, we simply return its value.
 
-If `fill-paragraph-function' is nil, return the `fill-prefix' used for filling."
+If `fill-paragraph-function' is nil, return the `fill-prefix' used for filling.
+
+Interactively (when `region' is non-nil) in Transient Mark mode when
+the mark is active, call `fill-region' to fill each of the paragraphs
+in the active region."
   (interactive (progn
 		 (barf-if-buffer-read-only)
-		 (list (if current-prefix-arg 'full))))
-  ;; First try fill-paragraph-function.
-  (or (and (not (eq fill-paragraph-function t))
-	   (or fill-paragraph-function
-	       (and (minibufferp (current-buffer))
-		    (= 1 (point-min))))
-	   (let ((function (or fill-paragraph-function
-			       ;; In the minibuffer, don't count the width
-			       ;; of the prompt.
-			       'fill-minibuffer-function))
-		 ;; If fill-paragraph-function is set, it probably takes care
-		 ;; of comments and stuff.  If not, it will have to set
-		 ;; fill-paragraph-handle-comment back to t explicitly or
-		 ;; return nil.
-		 (fill-paragraph-handle-comment nil)
-		 (fill-paragraph-function t))
-	     (funcall function arg)))
-      ;; Then try our syntax-aware filling code.
-      (and fill-paragraph-handle-comment
-	   ;; Our code only handles \n-terminated comments right now.
-	   comment-start (equal comment-end "")
-	   (let ((fill-paragraph-handle-comment nil))
-	     (fill-comment-paragraph arg)))
-      ;; If it all fails, default to the good ol' text paragraph filling.
-      (let ((before (point))
-	    (paragraph-start paragraph-start)
-	    ;; Fill prefix used for filling the paragraph.
-	    fill-pfx)
-	;; Try to prevent code sections and comment sections from being
-	;; filled together.
-	(when (and fill-paragraph-handle-comment comment-start-skip)
-	  (setq paragraph-start
-		(concat paragraph-start "\\|[ \t]*\\(?:"
-			comment-start-skip "\\)")))
-	(save-excursion
-	  ;; To make sure the return value of forward-paragraph is meaningful,
-	  ;; we have to start from the beginning of line, otherwise skipping
-	  ;; past the last few chars of a paragraph-separator would count as
-	  ;; a paragraph (and not skipping any chars at EOB would not count
-	  ;; as a paragraph even if it is).
-	  (move-to-left-margin)
-	  (if (not (zerop (forward-paragraph)))
-	      ;; There's no paragraph at or after point: give up.
-	      (setq fill-pfx "")
-	    (let ((end (point))
-		  (beg (progn (backward-paragraph) (point))))
-	      (goto-char before)
-	      (setq fill-pfx
-		    (if use-hard-newlines
-			;; Can't use fill-region-as-paragraph, since this
-			;; paragraph may still contain hard newlines.  See
-			;; fill-region.
-			(fill-region beg end arg)
-		      (fill-region-as-paragraph beg end arg))))))
-	fill-pfx)))
+		 (list (if current-prefix-arg 'full) t)))
+  (or
+   ;; 1. Fill the region if it is active when called interactively.
+   (and region transient-mark-mode mark-active
+	(not (eq (region-beginning) (region-end)))
+	(fill-region (region-beginning) (region-end) justify))
+   ;; 2. Try fill-paragraph-function.
+   (and (not (eq fill-paragraph-function t))
+	(or fill-paragraph-function
+	    (and (minibufferp (current-buffer))
+		 (= 1 (point-min))))
+	(let ((function (or fill-paragraph-function
+			    ;; In the minibuffer, don't count the width
+			    ;; of the prompt.
+			    'fill-minibuffer-function))
+	      ;; If fill-paragraph-function is set, it probably takes care
+	      ;; of comments and stuff.  If not, it will have to set
+	      ;; fill-paragraph-handle-comment back to t explicitly or
+	      ;; return nil.
+	      (fill-paragraph-handle-comment nil)
+	      (fill-paragraph-function t))
+	  (funcall function justify)))
+   ;; 3. Try our syntax-aware filling code.
+   (and fill-paragraph-handle-comment
+	;; Our code only handles \n-terminated comments right now.
+	comment-start (equal comment-end "")
+	(let ((fill-paragraph-handle-comment nil))
+	  (fill-comment-paragraph justify)))
+   ;; 4. If it all fails, default to the good ol' text paragraph filling.
+   (let ((before (point))
+	 (paragraph-start paragraph-start)
+	 ;; Fill prefix used for filling the paragraph.
+	 fill-pfx)
+     ;; Try to prevent code sections and comment sections from being
+     ;; filled together.
+     (when (and fill-paragraph-handle-comment comment-start-skip)
+       (setq paragraph-start
+	     (concat paragraph-start "\\|[ \t]*\\(?:"
+		     comment-start-skip "\\)")))
+     (save-excursion
+       ;; To make sure the return value of forward-paragraph is meaningful,
+       ;; we have to start from the beginning of line, otherwise skipping
+       ;; past the last few chars of a paragraph-separator would count as
+       ;; a paragraph (and not skipping any chars at EOB would not count
+       ;; as a paragraph even if it is).
+       (move-to-left-margin)
+       (if (not (zerop (forward-paragraph)))
+	   ;; There's no paragraph at or after point: give up.
+	   (setq fill-pfx "")
+	 (let ((end (point))
+	       (beg (progn (backward-paragraph) (point))))
+	   (goto-char before)
+	   (setq fill-pfx
+		 (if use-hard-newlines
+		     ;; Can't use fill-region-as-paragraph, since this
+		     ;; paragraph may still contain hard newlines.  See
+		     ;; fill-region.
+		     (fill-region beg end justify)
+		   (fill-region-as-paragraph beg end justify))))))
+     fill-pfx)))
 
 (defun fill-comment-paragraph (&optional justify)
   "Fill current comment.
@@ -1012,18 +1021,6 @@
 	  (goto-char end))))
     fill-pfx))
 
-(defun fill-paragraph-or-region (arg)
-  "Fill the active region or current paragraph.
-In Transient Mark mode, when the mark is active, it calls `fill-region'
-on the active region.  Otherwise, it calls `fill-paragraph'."
-  (interactive (progn
-		 (barf-if-buffer-read-only)
-		 (list (if current-prefix-arg 'full))))
-  (if (and transient-mark-mode mark-active
-	   (not (eq (region-beginning) (region-end))))
-      (fill-region (region-beginning) (region-end) arg)
-    (fill-paragraph arg)))
-
 
 (defcustom default-justification 'left
   "*Method of justifying text not otherwise specified.
@@ -1367,8 +1364,8 @@
 When calling from a program, pass the range to fill
 as the first two arguments.
 
-Optional third and fourth arguments JUSTIFY and MAIL-FLAG:
-JUSTIFY to justify paragraphs (prefix arg),
+Optional third and fourth arguments JUSTIFY and CITATION-REGEXP:
+JUSTIFY to justify paragraphs (prefix arg).
 When filling a mail message, pass a regexp for CITATION-REGEXP
 which will match the prefix of a line which is a citation marker
 plus whitespace, but no other kind of prefix.
@@ -1456,6 +1453,7 @@
 	    (fill-region-as-paragraph start (point) justify)
 	    (if (and (bolp) (not had-newline))
 		(delete-char -1))))))))
+
 (defun fill-individual-paragraphs-prefix (citation-regexp)
   (let* ((adaptive-fill-first-line-regexp ".*")
 	 (just-one-line-prefix
--- a/lisp/textmodes/ispell.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/textmodes/ispell.el	Fri Oct 19 00:00:21 2007 +0000
@@ -1536,7 +1536,7 @@
 	(translate-region pos (point) translation-table-for-input))))
 
 ;;;###autoload
-(defun ispell-word (&optional following quietly continue)
+(defun ispell-word (&optional following quietly continue region)
   "Check spelling of word under or before the cursor.
 If the word is not found in dictionary, display possible corrections
 in a window allowing you to choose one.
@@ -1550,6 +1550,9 @@
 With a prefix argument (or if CONTINUE is non-nil),
 resume interrupted spell-checking of a buffer or region.
 
+Interactively, in Transient Mark mode when the mark is active, call
+`ispell-region' to check the active region for spelling errors.
+
 Word syntax is controlled by the definition of the chosen dictionary,
 which is in `ispell-local-dictionary-alist' or `ispell-dictionary-alist'.
 
@@ -1562,10 +1565,9 @@
 \"word\"        word corrected from word list.
 \(\"word\" arg\)  word is hand entered.
 quit          spell session exited."
-
-  (interactive (list ispell-following-word ispell-quietly current-prefix-arg))
+  (interactive (list ispell-following-word ispell-quietly current-prefix-arg t))
   (cond
-   ((and transient-mark-mode mark-active
+   ((and region transient-mark-mode mark-active
 	 (not (eq (region-beginning) (region-end))))
     (ispell-region (region-beginning) (region-end)))
    (continue (ispell-continue))
--- a/lisp/textmodes/org.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/textmodes/org.el	Fri Oct 19 00:00:21 2007 +0000
@@ -129,7 +129,7 @@
 	 (progn
 	   (if pc-mode (partial-completion-mode -1))
 	   ,@body)
-       (if pc-mode (partial-completion-mode 1)))))  
+       (if pc-mode (partial-completion-mode 1)))))
 
 ;;; The custom variables
 
@@ -1399,7 +1399,7 @@
 `C-u C-c C-c' trigger the fasttrack."
   :group 'org-remember
   :type 'boolean)
-  
+
 (defcustom org-remember-default-headline ""
   "The headline that should be the default location in the notes file.
 When filing remember notes, the cursor will start at that position.
@@ -2702,7 +2702,7 @@
 	  (repeat
 	   (cons
 	    (choice :tag "Type"
-		    (const :html) (const :LaTeX) 
+		    (const :html) (const :LaTeX)
 		    (const :ascii) (const :ical) (const :xoxo))
 	    (directory)))))
 
@@ -3516,7 +3516,7 @@
   ;; Make sure that a fixed-width face is used when we have a column table.
   (set-face-attribute 'org-column nil
 		      :height (face-attribute 'default :height)
-		      :family (face-attribute 'default :family)))  
+		      :family (face-attribute 'default :family)))
 
 (defface org-warning
   (org-compatible-face
@@ -5544,7 +5544,7 @@
   (cond
    ((org-on-heading-p) (org-do-demote))
    ((org-at-item-p) (org-indent-item 1))))
-  
+
 ;;; Promotion and Demotion
 
 (defun org-promote-subtree ()
@@ -6064,7 +6064,7 @@
 	      (if (string-match org-priority-regexp x)
 		  (string-to-char (match-string 2 x))
 		org-default-priority))
-	    comparefun (if (= dcst sorting-type) '< '>)))		  
+	    comparefun (if (= dcst sorting-type) '< '>)))
      (t (error "Invalid sorting type `%c'" sorting-type)))
 
     (sort (mapcar (lambda (x) (cons (funcall extractfun (car x)) (cdr x)))
@@ -6778,7 +6778,7 @@
 		(orgstruct-make-binding 'org-cycle 102 [(tab)] "\C-i"))
     (org-defkey orgstruct-mode-map "\C-i"
 		(orgstruct-make-binding 'org-cycle 103 "\C-i" [(tab)]))
-    
+
     (org-defkey orgstruct-mode-map "\M-\C-m"
 		(orgstruct-make-binding 'org-insert-heading 105
 				     "\M-\C-m" [(meta return)]))
@@ -6789,10 +6789,10 @@
     (org-defkey orgstruct-mode-map [(shift meta return)]
 		(orgstruct-make-binding 'org-insert-todo-heading 107
 				     [(meta return)] "\M-\C-m"))
-    
+
     (unless org-local-vars
       (setq org-local-vars (org-get-local-variables)))
-    
+
     t))
 
 (defun orgstruct-make-binding (fun n &rest keys)
@@ -6843,7 +6843,7 @@
     (kill-buffer "*Org tmp*")
     (delq nil
 	  (mapcar
-	   (lambda (x) 
+	   (lambda (x)
 	     (setq x
 		   (if (symbolp x)
 		       (list x)
@@ -11258,12 +11258,12 @@
 	  (if description (concat "[" description "]") "")
 	  "]"))
 
-(defconst org-link-escape-chars 
+(defconst org-link-escape-chars
   '((" " . "%20")
     ("[" . "%5B")
     ("]" . "%5d")
     ("\340" . "%E0")  ; `a
-    ("\342" . "%E2")  ; ^a  
+    ("\342" . "%E2")  ; ^a
     ("\347" . "%E7")  ; ,c
     ("\350" . "%E8")  ; `e
     ("\351" . "%E9")  ; 'e
@@ -11280,7 +11280,7 @@
   "Association list of escapes for some characters problematic in links.
 This is the list that is used for internal purposes.")
 
-(defconst org-link-escape-chars-browser 
+(defconst org-link-escape-chars-browser
   '((" " . "%20"))
   "Association list of escapes for some characters problematic in links.
 This is the list that is used before handing over to the browser.")
@@ -11459,7 +11459,7 @@
 	  (setq org-stored-links (delq (assoc link org-stored-links)
 				       org-stored-links)))
       (setq desc (or desc (nth 1 entry)))))
-    
+
     (if (string-match org-plain-link-re link)
 	;; URL-like link, normalize the use of angular brackets.
 	(setq link (org-make-link (org-remove-angle-brackets link))))
@@ -12537,7 +12537,7 @@
 	      (when (string-match "\\S-" ins)
 		(or (equal (char-before) ?:) (insert ":"))
 		(insert ins)
-		(or (equal (char-after) ?:) (insert ":")))))		
+		(or (equal (char-after) ?:) (insert ":")))))
 	   (char
 	    (setq org-time-was-given (equal (upcase char) char))
 	    (setq time (org-read-date (equal (upcase char) "U") t nil
@@ -12710,7 +12710,7 @@
 		     (org-end-of-subtree t)
 		     (org-paste-subtree level txt))
 		    (t (error "This should not happen"))))
-		  
+
 		  ((and (bobp) (not reversed))
 		   ;; Put it at the end, one level below level 1
 		   (save-restriction
@@ -12718,7 +12718,7 @@
 		     (goto-char (point-max))
 		     (if (not (bolp)) (newline))
 		     (org-paste-subtree (org-get-legal-level 1 1) txt)))
-		  
+
 		  ((and (bobp) reversed)
 		   ;; Put it at the start, as level 1
 		   (save-restriction
@@ -13834,7 +13834,7 @@
       (setq match (completing-read
 		   "Match: " 'org-tags-completion-function nil nil nil
 		   'org-tags-history))))
-  
+
   ;; Parse the string and create a lisp form
   (let ((match0 match)
 	(re (org-re "^&?\\([-+:]\\)?\\({[^}]+}\\|LEVEL=\\([0-9]+\\)\\|\\([[:alnum:]]+\\)=\\({[^}]+}\\|\"[^\"]+\"\\)\\|[[:alnum:]_@]+\\)"))
@@ -13997,12 +13997,12 @@
 	(while (string-match "[-+&]+" tags)
 	  ;; No boolean logic, just a list
 	  (setq tags (replace-match ":" t t tags))))
-      
+
       (if (string-match "\\`[\t ]*\\'" tags)
           (setq tags "")
 	(unless (string-match ":$" tags) (setq tags (concat tags ":")))
 	(unless (string-match "^:" tags) (setq tags (concat ":" tags))))
-      
+
       ;; Insert new tags at the correct column
       (beginning-of-line 1)
       (cond
@@ -14321,7 +14321,7 @@
   (let (tags)
     (save-excursion
       (goto-char (point-min))
-      (while (re-search-forward 
+      (while (re-search-forward
 	      (org-re "[ \t]:\\([[:alnum:]_@:]+\\):[ \t\r\n]") nil t)
 	(when (equal (char-after (point-at-bol 0)) ?*)
 	  (mapc (lambda (x) (add-to-list 'tags x))
@@ -14469,7 +14469,7 @@
 		(unless (member key excluded)
 		  (push (cons key (or value "")) props)))))
 	  (append sum-props (nreverse props)))))))
-  
+
 (defun org-entry-get (pom property &optional inherit)
   "Get value of PROPERTY for entry at point-or-marker POM.
 If INHERIT is non-nil and the entry does not have the property,
@@ -14636,7 +14636,7 @@
 (defun org-set-property (property value)
   "In the current entry, set PROPERTY to VALUE."
   (interactive
-   (let* ((prop	(completing-read "Property: " 
+   (let* ((prop	(completing-read "Property: "
 				 (mapcar 'list (org-buffer-property-keys))))
 	  (cur (org-entry-get nil prop))
 	  (allowed (org-property-get-allowed-values nil prop 'table))
@@ -14657,7 +14657,7 @@
    (let* ((prop (completing-read
 		 "Property: " (org-entry-properties nil 'standard))))
      (list prop)))
-  (message (concat "Property " property 
+  (message (concat "Property " property
 		   (if (org-entry-delete nil property)
 		       " deleted"
 		     " was not present in the entry"))))
@@ -14666,7 +14666,7 @@
   "Remove PROPERTY globally, from all entries."
   (interactive
    (let* ((prop (completing-read
-		 "Globally remove property: " 
+		 "Globally remove property: "
 		 (mapcar 'list (org-buffer-property-keys)))))
      (list prop)))
   (save-excursion
@@ -14703,7 +14703,7 @@
   (let (vals)
     (cond
      ((equal property "TODO")
-      (setq vals (org-with-point-at pom 
+      (setq vals (org-with-point-at pom
 		   (append org-todo-keywords-1 '("")))))
      ((equal property "PRIORITY")
       (let ((n org-lowest-priority))
@@ -14713,7 +14713,7 @@
      ((member property org-special-properties))
      (t
       (setq vals (org-entry-get pom (concat property "_ALL") 'inherit))
-	    
+
       (when (and vals (string-match "\\S-" vals))
 	(setq vals (car (read-from-string (concat "(" vals ")"))))
 	(setq vals (mapcar (lambda (x)
@@ -14843,7 +14843,7 @@
 		       (beginning-of-line 1)
 		       (and (looking-at "\\(\\**\\)\\(\\* \\)")
 			    (org-get-level-face 2))))
-	 (color (list :foreground 
+	 (color (list :foreground
 		      (face-attribute (or level-face 'default) :foreground)))
 	 props pom property ass width f string ov column)
     ;; Check if the entry is in another buffer.
@@ -14988,7 +14988,7 @@
 	 nval eval allowed)
     (when (equal key "ITEM")
       (error "Cannot edit item headline from here"))
-    
+
     (cond
      ((equal key "TODO")
       (setq eval '(org-with-point-at pom
@@ -15021,7 +15021,7 @@
 	(remove-text-properties (1- bol) eol '(read-only t))
 	(unwind-protect
 	    (progn
-	      (setq org-columns-overlays 
+	      (setq org-columns-overlays
 		    (org-delete-all line-overlays org-columns-overlays))
 	      (mapc 'org-delete-overlay line-overlays)
 	      (org-columns-eval eval))
@@ -15040,7 +15040,7 @@
 	 (allowed (org-entry-get (point) key1 t))
 	 nval)
     (setq nval (read-string "Allowed: " allowed))
-    (org-entry-put 
+    (org-entry-put
      (cond ((marker-position org-entry-property-inherited-from)
 	    org-entry-property-inherited-from)
 	   ((marker-position org-columns-top-level-marker)
@@ -15050,8 +15050,7 @@
 (defun org-columns-eval (form)
   (let (hidep)
     (save-excursion
-      (beginning-of-line 1)
-      (next-line 1)
+      (forward-line 1)
       (setq hidep (org-on-heading-p 1)))
     (eval form)
     (and hidep (hide-entry))))
@@ -15099,7 +15098,7 @@
       (remove-text-properties (1- bol) eol '(read-only t))
       (unwind-protect
 	  (progn
-	    (setq org-columns-overlays 
+	    (setq org-columns-overlays
 		  (org-delete-all line-overlays org-columns-overlays))
 	    (mapc 'org-delete-overlay line-overlays)
 	    (org-columns-eval '(org-entry-put pom key nval)))
@@ -15250,7 +15249,7 @@
       (error "Cannot shift this column further to the left"))
     (backward-char 1)
     (org-columns-move-right)
-    (backward-char 1)))    
+    (backward-char 1)))
 
 (defun org-columns-store-format ()
   "Store the text version of the current columns format in appropriate place.
@@ -15348,7 +15347,7 @@
 		(setq pos (org-overlay-start ov))
 		(goto-char pos)
 		(when (setq val (cdr (assoc property
-					    (get-text-property 
+					    (get-text-property
 					     (point-at-bol) 'org-summaries))))
 		  (setq fmt (org-overlay-get ov 'org-columns-format))
 		  (org-overlay-put ov 'org-columns-value val)
@@ -15404,7 +15403,7 @@
 					      (if flag str val) format))))
 	    (aset lflag level t))
 	  ;; clear accumulators for deeper levels
-	  (loop for l from (1+ level) to (1- lmax) do 
+	  (loop for l from (1+ level) to (1- lmax) do
 		(aset lsum l 0)
 		(aset lflag l nil)))
 	 ((>= level last-level)
@@ -15720,7 +15719,7 @@
 		  minute (if (match-end 3)
 			     (string-to-number (match-string 3 ans))
 			   0)
-		  pm (equal ?p 
+		  pm (equal ?p
 			    (string-to-char (downcase (match-string 4 ans)))))
 	    (if (and (= hour 12) (not pm))
 		(setq hour 0)
@@ -16354,7 +16353,7 @@
 	(setq ng 6 new (car (rassoc (+ n (cdr (assoc (match-string 6 s) idx))) idx))))
        ((org-pos-in-match-range pos 5)
 	(setq ng 5 new (format "%d" (max 1 (+ n (string-to-number (match-string 5 s))))))))
-	
+
       (when ng
 	(setq s (concat
 		 (substring s 0 (match-beginning ng))
@@ -16421,28 +16420,28 @@
   (require 'org)
   (if (equal filter '(4))
       (setq filter (read-from-minibuffer "Regexp filter: ")))
-  (let* ((today (org-date-to-gregorian 
+  (let* ((today (org-date-to-gregorian
 		 (time-to-days (current-time))))
 	 (files org-agenda-files) entries file)
     (while (setq file (pop files))
       (setq entries (append entries (org-agenda-get-day-entries
 				     file today :timestamp))))
     (setq entries (delq nil entries))
-    (mapc 
+    (mapc
      (lambda(x)
        (let* ((evt (org-trim (get-text-property 1 'txt x)))
 	      (cat (get-text-property 1 'org-category x))
 	      (tod (get-text-property 1 'time-of-day x))
 	      (ok (or (and (stringp filter) (string-match filter evt))
 		      (and (not (null filter)) (listp filter)
-			   (or (string-match 
+			   (or (string-match
 				(cadr (assoc 'category filter)) cat)
-			       (string-match 
+			       (string-match
 				(cadr (assoc 'headline filter)) evt))))))
 	      ;; (setq evt (set-text-properties 0 (length event) nil evt))
 	 (when (and ok tod)
 	   (setq tod (number-to-string tod)
-		 tod (when (string-match 
+		 tod (when (string-match
 			    "\\([0-9]\\{1,2\\}\\)\\([0-9]\\{2\\}\\)" tod)
 		       (concat (match-string 1 tod) ":"
 			       (match-string 2 tod))))
@@ -16923,7 +16922,7 @@
 	      (setq total-time (+ (or total-time 0)
 				  org-clock-file-total-minutes)))))))
       (goto-char pos)
-      
+
       (unless (eq scope 'agenda)
 	(org-clock-sum ts te)
 	(goto-char (point-min))
@@ -16968,7 +16967,7 @@
 	(insert-before-markers
 	 "|-\n|"
 	 (if (eq scope 'agenda) "|" "")
-	 "|" 
+	 "|"
 	 "*Total time*| "
 	 (format "*%d:%02d*" h m)
 	 "|\n|-\n")
@@ -19766,7 +19765,7 @@
 	   (list (car org-agenda-last-arguments) sd nd t)))
     (org-agenda-redo)
     (org-agenda-find-today-or-agenda))))
- 
+
 (defun org-agenda-earlier (arg)
   "Go backward in time by the current span.
 With prefix ARG, go backward that many times the current span."
@@ -20480,7 +20479,7 @@
   (save-excursion
     (org-back-to-heading t)
     (if (looking-at
-	 (if no-tags 
+	 (if no-tags
 	     (org-re "\\*+[ \t]+\\([^\n\r]*?\\)\\([ \t]+:[[:alnum:]:_@]+:[ \t]*\\)?$")
 	   "\\*+[ \t]+\\([^\r\n]*\\)"))
 	(match-string 1) "")))
@@ -21530,7 +21529,7 @@
 	  (setq fmt (pop formatters))
 	  (when (car fmt)
 	    (goto-char (point-min))
-	    (while (re-search-forward (concat "^#\\+" (cadr fmt) 
+	    (while (re-search-forward (concat "^#\\+" (cadr fmt)
 					      ":[ \t]*\\(.*\\)") nil t)
 	      (replace-match "\\1" t)
 	      (add-text-properties
@@ -21538,7 +21537,7 @@
 	       '(org-protected t))))
 	  (goto-char (point-min))
 	  (while (re-search-forward
-		  (concat "^#\\+" 
+		  (concat "^#\\+"
 			  (caddr fmt) "\\>.*\\(\\(\n.*\\)*?\n\\)#\\+"
 			  (cadddr fmt) "\\>.*\n?") nil t)
 	    (if (car fmt)
@@ -21689,7 +21688,7 @@
 	 (add-text-properties (point) (1+ (point-at-eol))
 			      (list :org-license-to-kill t)))))
     title))
-	 
+
 (defun org-solidify-link-text (s &optional alist)
   "Take link text and make a safe target out of it."
   (save-match-data
@@ -22778,7 +22777,7 @@
 	  (if (and (string-match org-todo-line-regexp line)
 		   (match-beginning 2))
 
-              (setq line 
+              (setq line
                     (concat (substring line 0 (match-beginning 2))
                             "<span class=\""
                             (if (member (match-string 2 line)
@@ -23112,14 +23111,14 @@
 	     (lambda (x)
 	       (setq gr (pop org-table-colgroup-info))
 	       (format "%s<COL align=\"%s\"></COL>%s"
-		       (if (memq gr '(:start :startend)) 
+		       (if (memq gr '(:start :startend))
 			   (prog1
 			       (if colgropen "</colgroup>\n<colgroup>" "<colgroup>")
 			     (setq colgropen t))
 			 "")
 		       (if (> (/ (float x) nlines) org-table-number-fraction)
 			   "right" "left")
-		       (if (memq gr '(:end :startend)) 
+		       (if (memq gr '(:end :startend))
 			   (progn (setq colgropen nil) "</colgroup>")
 			 "")))
 	     fnum "")
--- a/lisp/time.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/time.el	Fri Oct 19 00:00:21 2007 +0000
@@ -127,7 +127,7 @@
   :type '(repeat (list string string))
   :version "23.1")
 
-(defcustom display-time-world-time-format "%A %m %B %R %Z"
+(defcustom display-time-world-time-format "%A %d %B %R %Z"
   "Format of the time displayed, see `format-time-string'."
   :group 'display-time
   :type 'string
--- a/lisp/tutorial.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/tutorial.el	Fri Oct 19 00:00:21 2007 +0000
@@ -291,7 +291,7 @@
              ;; * MODE LINE
              (describe-mode [?\C-h ?m])
              (set-fill-column [?\C-x ?f])
-             (fill-paragraph-or-region [?\M-q])
+             (fill-paragraph [?\M-q])
 
              ;; * SEARCHING
              (isearch-forward [?\C-s])
@@ -665,7 +665,8 @@
   ;; This runs in a hook so protect it:
   (condition-case err
       (if (y-or-n-p "Save your position in the tutorial? ")
-	  (tutorial--save-tutorial-to (tutorial--saved-file)))
+	  (tutorial--save-tutorial-to (tutorial--saved-file))
+	(message "Tutorial position not saved"))
     (error (message "Error saving tutorial state: %s"
 		    (error-message-string err)))))
 
--- a/lisp/vc-hooks.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/vc-hooks.el	Fri Oct 19 00:00:21 2007 +0000
@@ -556,6 +556,13 @@
       (if (vc-backend file)
           (vc-file-setprop file 'vc-working-revision
                            (vc-call working-revision file)))))
+;; Backward compatibility.
+(define-obsolete-function-alias
+  'vc-workfile-version 'vc-working-revision "23.1")
+(defun vc-default-working-revision (backend file)
+  (message
+   "`working-revision' not found: using the old `workfile-version' instead")
+  (vc-call-backend backend 'workfile-version file))
 
 (defun vc-default-registered (backend file)
   "Check if FILE is registered in BACKEND using vc-BACKEND-master-templates."
--- a/lisp/vc.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/vc.el	Fri Oct 19 00:00:21 2007 +0000
@@ -1873,24 +1873,17 @@
 (make-obsolete 'vc-diff-switches-list 'vc-switches "22.1")
 
 (defun vc-diff-sentinel (verbose rev1-name rev2-name)
-  ;; Did changes get generated into the buffer?
-  (if (not (zerop (buffer-size (get-buffer "*vc-diff*"))))
-      (progn
-	(pop-to-buffer "*vc-diff*")
-	;; Gnus-5.8.5 sets up an autoload for diff-mode, even if it's
-	;; not available.  Work around that.
-	(if (require 'diff-mode nil t) (diff-mode))
-	(when verbose
-	  (let (buffer-read-only)
-	    (goto-char (point-max))
-	    (insert (format "\n\nDiffs between %s and %s end here." rev1-name rev2-name))
-	    (goto-char (point-min))
-	    (insert (format "Diffs between %s and %s:\n\n" rev1-name rev2-name))))
-	(shrink-window-if-larger-than-buffer)
-	t)
-    (progn
-      (message "No changes between %s and %s" rev1-name rev2-name)
-      nil)))
+  ;; The empty sync output case has already been handled, so the only
+  ;; possibility of an empty output is for an async process, in which case
+  ;; it's important to insert the "diffs end here" message in the buffer
+  ;; since the user may miss a message in the echo area.
+  (when verbose
+    (let ((inhibit-read-only t))
+      (if (eq (buffer-size) 0)
+          (insert "No differences found.\n")
+        (insert (format "\n\nDiffs between %s and %s end here." rev1-name rev2-name)))))
+  (goto-char (point-min))
+  (shrink-window-if-larger-than-buffer))
 
 (defun vc-diff-internal (backend async files rev1 rev2 &optional verbose)
   "Report diffs between two revisions of a fileset.
@@ -1927,12 +1920,20 @@
       (let ((vc-disable-async-diff (not async)))
 	(vc-call-backend backend 'diff filtered rev1 rev2 "*vc-diff*")))
     (set-buffer "*vc-diff*")
-    ;; This odd-looking code is because in the non-async case we 
-    ;; actually want to pass the return value from vc-diff-sentinel
-    ;; back to the caller.
-    (if async
-	(vc-exec-after `(vc-diff-sentinel ,verbose ,rev1-name ,rev2-name))
-     (vc-diff-sentinel verbose rev1-name rev2-name))))
+    (if (and (zerop (buffer-size))
+             (not (get-buffer-process (current-buffer))))
+        ;; Treat this case specially so as not to pop the buffer.
+        (progn
+          (message "No changes between %s and %s" rev1-name rev2-name)
+          nil)
+      (pop-to-buffer (current-buffer))
+      ;; Gnus-5.8.5 sets up an autoload for diff-mode, even if it's
+      ;; not available.  Work around that.
+      (if (require 'diff-mode nil t) (diff-mode))
+      (vc-exec-after `(vc-diff-sentinel ,verbose ,rev1-name ,rev2-name))
+      ;; In the async case, we return t even if there are no differences
+      ;; because we don't know that yet.
+      t)))
 
 ;;;###autoload
 (defun vc-history-diff (backend files rev1 rev2)
@@ -3031,10 +3032,7 @@
     (vc-register)))
 
 (defalias 'vc-default-logentry-check 'ignore)
-
-(defun vc-default-check-headers (backend)
-  "Default implementation of check-headers; always returns nil."
-  nil)
+(defalias 'vc-default-check-headers 'ignore)
 
 (defun vc-default-log-view-mode (backend) (log-view-mode))
 
@@ -3116,7 +3114,7 @@
               (and (not vc-make-backup-files) (delete-file backup-name))))))
       (message "Checking out %s...done" file))))
 
-(defun vc-default-revision-completion-table (backend file) nil)
+(defalias 'vc-default-revision-completion-table 'ignore)
 
 (defun vc-check-headers ()
   "Check if the current file has any headers in it."
--- a/lisp/xt-mouse.el	Mon Oct 15 15:43:53 2007 +0000
+++ b/lisp/xt-mouse.el	Fri Oct 19 00:00:21 2007 +0000
@@ -45,9 +45,6 @@
 
 (defvar xterm-mouse-debug-buffer nil)
 
-;; XXX Perhaps this should be terminal-local instead. --lorentey
-(define-key function-key-map "\e[M" 'xterm-mouse-translate)
-
 (defvar xterm-mouse-last)
 
 ;; Mouse events symbols must have an 'event-kind property with
@@ -78,7 +75,7 @@
 	    (error "Unexpected escape sequence from XTerm")))
 
 	(let* ((click (if is-click down (xterm-mouse-event)))
-	       (click-command (nth 0 click))
+	       ;; (click-command (nth 0 click))
 	       (click-data (nth 1 click))
 	       (click-where (nth 1 click-data)))
 	  (if (memq down-binding '(nil ignore))
@@ -209,14 +206,15 @@
       ;; Turn it on
       (progn
 	;; Frame creation and deletion.
-	(add-hook 'after-make-frame-functions 
-		  'turn-on-xterm-mouse-tracking-on-terminal)
+        (add-hook 'terminal-init-xterm-hook
+                  'turn-on-xterm-mouse-tracking-on-terminal)
+
 	(add-hook 'delete-frame-functions 'xterm-mouse-handle-delete-frame)
 	
 	;; Restore normal mouse behaviour outside Emacs.
         (add-hook 'suspend-tty-functions
 		  'turn-off-xterm-mouse-tracking-on-terminal)
-	(add-hook 'resume-tty-functions 
+	(add-hook 'resume-tty-functions
 		  'turn-on-xterm-mouse-tracking-on-terminal)
 	(add-hook 'suspend-hook 'turn-off-xterm-mouse-tracking)
 	(add-hook 'suspend-resume-hook 'turn-on-xterm-mouse-tracking)
@@ -224,8 +222,6 @@
 	(setq mouse-position-function #'xterm-mouse-position-function)
 	(turn-on-xterm-mouse-tracking))
     ;; Turn it off
-    (remove-hook 'after-make-frame-functions 
-		 'turn-on-xterm-mouse-tracking-on-terminal)
     (remove-hook 'delete-frame-functions 'xterm-mouse-handle-delete-frame)
     (remove-hook 'suspend-tty-functions 
 		 'turn-off-xterm-mouse-tracking-on-terminal)
@@ -239,28 +235,35 @@
 
 (defun turn-on-xterm-mouse-tracking ()
   "Enable Emacs mouse tracking in xterm."
-  (dolist (f (frame-list))
-    (when (eq t (frame-live-p f))
-      (with-selected-frame f
-	(when xterm-mouse-mode
-	  (send-string-to-terminal "\e[?1000h"))))))
+  (dolist (terminal (delete-dups (mapcar 'frame-terminal (frame-list))))
+    (turn-on-xterm-mouse-tracking-on-terminal terminal)))
 
 (defun turn-off-xterm-mouse-tracking (&optional force)
   "Disable Emacs mouse tracking in xterm."
-  (dolist (f (frame-list))
-    (when (eq t (frame-live-p f))
-      (with-selected-frame f
-	(when (or force xterm-mouse-mode)
-	  (send-string-to-terminal "\e[?1000l"))))))
+  (dolist (terminal (delete-dups (mapcar 'frame-terminal (frame-list))))
+    (turn-off-xterm-mouse-tracking-on-terminal terminal)))
 
-(defun turn-on-xterm-mouse-tracking-on-terminal (terminal)
+(defun turn-on-xterm-mouse-tracking-on-terminal (&optional terminal)
   "Enable xterm mouse tracking on TERMINAL."
   (when (and xterm-mouse-mode (eq t (terminal-live-p terminal)))
+    (unless (terminal-parameter terminal 'xterm-mouse-mode)
+      ;; Simulate selecting a terminal by selecting one of its frames ;-(
+      (with-selected-frame (car (frames-on-display-list terminal))
+        (define-key input-decode-map "\e[M" 'xterm-mouse-translate))
+      (set-terminal-parameter terminal 'xterm-mouse-mode t))
     (send-string-to-terminal "\e[?1000h" terminal)))
 
 (defun turn-off-xterm-mouse-tracking-on-terminal (terminal)
   "Disable xterm mouse tracking on TERMINAL."
-  (when (and xterm-mouse-mode (eq t (terminal-live-p terminal)))
+  ;; Only send the disable command to those terminals to which we've already
+  ;; sent the enable command.
+  (when (and (terminal-parameter terminal 'xterm-mouse-mode)
+             (eq t (terminal-live-p terminal)))
+    ;; We could remove the key-binding and unset the `xterm-mouse-mode'
+    ;; terminal parameter, but it seems less harmful to send this escape
+    ;; command too many times (or to catch an unintended key sequence), than
+    ;; to send it too few times (or to fail to let xterm-mouse events
+    ;; pass by untranslated).
     (send-string-to-terminal "\e[?1000l" terminal)))
 
 (defun xterm-mouse-handle-delete-frame (frame)
--- a/nt/ChangeLog	Mon Oct 15 15:43:53 2007 +0000
+++ b/nt/ChangeLog	Fri Oct 19 00:00:21 2007 +0000
@@ -1,3 +1,7 @@
+2007-10-18  Jason Rumney  <jasonr@gnu.org>
+
+	* makefile.w32-in (install): Install COPYING in top-level and bin dirs.
+
 2007-09-27  Jason Rumney  <jasonr@gnu.org>
 
 	* gmake.defs (COMCTL32): New system library.
--- a/nt/makefile.w32-in	Mon Oct 15 15:43:53 2007 +0000
+++ b/nt/makefile.w32-in	Fri Oct 19 00:00:21 2007 +0000
@@ -211,6 +211,8 @@
 	$(IFNOTSAMEDIR) $(CP_DIR) ../etc $(INSTALL_DIR) $(ENDIF)
 	- $(CP_DIR) icons $(INSTALL_DIR)/etc
 	$(IFNOTSAMEDIR) $(CP_DIR) ../info $(INSTALL_DIR) $(ENDIF)
+	$(IFNOTSAMEDIR) $(CP) ../COPYING $(INSTALL_DIR) $(ENDIF)
+	- $(CP) ../COPYING $(INSTALL_DIR)/bin
 	- $(DEL) ../same-dir.tst
 	- $(DEL) $(INSTALL_DIR)/same-dir.tst
 
--- a/src/ChangeLog	Mon Oct 15 15:43:53 2007 +0000
+++ b/src/ChangeLog	Fri Oct 19 00:00:21 2007 +0000
@@ -1,3 +1,103 @@
+2007-10-18  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* keyboard.c (read_key_sequence): Undo a change introduced by multi-tty
+	which caused key-translation-map to applied repeatedly (thus breaking
+	double-mode).
+
+2007-10-17  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* xselect.c (x_own_selection, x_handle_selection_clear)
+	(x_clear_frame_selections):
+	* w32menu.c (list_of_panes, list_of_items):
+	* w32fns.c (w32_color_map_lookup, Fx_create_frame, Fx_display_list):
+	* textprop.c (validate_plist, interval_has_all_properties)
+	(interval_has_some_properties, interval_has_some_properties_list)
+	(add_properties, text_property_list):
+	* process.c (Fget_buffer_process, list_processes_1, status_notify):
+	* minibuf.c (Fassoc_string):
+	* macselect.c (x_own_selection, x_clear_frame_selections)
+	(Fx_disown_selection_internal):
+	* keymap.c (Fcommand_remapping, where_is_internal, describe_map_tree):
+	Use CONSP rather than !NILP and XC[AD]R rather than Fc[ad]r.
+
+2007-10-17  Chong Yidong  <cyd@stupidchicken.com>
+
+	* process.c: Link to libs for calling res_init() if available.
+	(Fmake_network_process): Call res_init() before getaddrinfo or
+	gethostbyname, if possible.
+
+2007-10-17  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* lread.c (read1): Set pvectype for char_tables.
+
+	* lisp.h (XMISCANY, XMARKER, XINTFWD, XBOOLFWD, XOBJFWD, XOVERLAY)
+	(XBUFFER_OBJFWD, XBUFFER_LOCAL_VALUE, XKBOARD_OBJFWD, XSAVE_VALUE):
+	Add type checks.
+	(SOME_BUFFER_LOCAL_VALUEP, GC_SOME_BUFFER_LOCAL_VALUEP): Remove.
+
+	* alloc.c (free_misc): Use XMISCTYPE.
+	(live_misc_p, gc_sweep): Use Lisp_Misc_Any.
+
+2007-10-17  Glenn Morris  <rgm@gnu.org>
+
+	* minibuf.c (Qcompletion_ignore_case): New Lisp_Object.
+	(syms_of_minibuf): Add Qcompletion_ignore_case.
+	* dired.c (Qcompletion_ignore_case): Change to external.
+	(syms_of_dired) [VMS]: Remove Qcompletion_ignore_case.
+	* fileio.c (Qcompletion_ignore_case): New external Lisp_Object.
+	(Fread_file_name): Use it rather than intern'ing.
+
+	* coding.c (Qcompletion_ignore_case): New external Lisp_Object.
+	(Fread_coding_system): Ignore case of user input.
+
+2007-10-16  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* xdisp.c (handle_display_prop): Ignore display specs after
+	replacing one when string text is being replaced.
+	(handle_single_display_spec): Pretend as if characters with display
+	property haven't been consumed only when buffer text is being replaced.
+
+2007-10-16  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* xfns.c (Fx_create_frame, Fx_display_list):
+	* window.c (window_fixed_size_p, enlarge_window)
+	(shrink_window_lowest_first):
+	* macterm.c (init_font_name_table):
+	* macfns.c (Fx_create_frame, Fx_display_list):
+	* lread.c (close_load_descs):
+	* keyboard.c (read_char_x_menu_prompt):
+	* fns.c (Fmember, Fmemql, Fdelete, Fset_char_table_parent):
+	* coding.c (code_convert_region_unwind): Test the type of an object
+	rather than just !NILP before extracting data from it.
+
+	* alloc.c (Fpurecopy): Set the pvec tag on pseudo vectors.
+
+	* lisp.h (enum Lisp_Misc_Type): Del Lisp_Misc_Some_Buffer_Local_Value.
+	(XMISCANY): New macro.
+	(XMISCTYPE): Use it.
+	(struct Lisp_Misc_Any): New type.
+	(union Lisp_Misc): Use it.
+	(struct Lisp_Buffer_Local_Value): Add `local_if_set' bit.
+	* data.c (Fboundp, store_symval_forwarding, swap_in_global_binding)
+	(find_symbol_value, set_internal, default_value, Fset_default)
+	(Fmake_variable_buffer_local, Fmake_local_variable)
+	(Fkill_local_variable, Fmake_variable_frame_local, Flocal_variable_p)
+	(Flocal_variable_if_set_p, Fvariable_binding_locus):
+	The SOME_BUFFER_LOCAL_VALUEP distinction is replaced by local_if_set.
+	* alloc.c (allocate_buffer): Set the size and tag.
+	(allocate_misc, mark_maybe_object, mark_object, survives_gc_p):
+	Use XMISCANY.
+	(die): Follow the GNU convention for error messages.
+	* print.c (print_object): SOME_BUFFER_LOCAL_VALUEP -> local_if_set.
+	* buffer.c (Fget_buffer_create, Fmake_indirect_buffer): Don't set the
+	tag any more.
+	(set_buffer_internal_1):
+	* frame.c (store_frame_param):
+	* eval.c (specbind):
+	* xdisp.c (select_frame_for_redisplay): Drop SOME_BUFFER_LOCAL_VALUEP.
+
+	* doc.c (Fsnarf_documentation): Simplify.
+
 2007-10-14  Juanma Barranquero  <lekktu@gmail.com>
 
 	* w32term.c (w32_font_is_double_byte, my_create_scrollbar): Make static.
@@ -68,6 +168,11 @@
 
 	* puresize.h (BASE_PURESIZE): Increase to 1170000.
 
+2007-10-09  Richard Stallman  <rms@gnu.org>
+
+	* xdisp.c (handle_invisible_prop): After setting up an ellipsis,
+	return HANDLED_RETURN.
+
 2007-10-08  Martin Rudalics  <rudalics@gmx.at>
 
 	* keyboard.c (kbd_buffer_get_event): Break loop waiting for input
--- a/src/alloc.c	Mon Oct 15 15:43:53 2007 +0000
+++ b/src/alloc.c	Fri Oct 19 00:00:21 2007 +0000
@@ -1153,6 +1153,8 @@
   struct buffer *b
     = (struct buffer *) lisp_malloc (sizeof (struct buffer),
 				     MEM_TYPE_BUFFER);
+  b->size = sizeof (struct buffer) / sizeof (EMACS_INT);
+  XSETPVECTYPE (b, PVEC_BUFFER);
   return b;
 }
 
@@ -3307,7 +3309,7 @@
   --total_free_markers;
   consing_since_gc += sizeof (union Lisp_Misc);
   misc_objects_consed++;
-  XMARKER (val)->gcmarkbit = 0;
+  XMISCANY (val)->gcmarkbit = 0;
   return val;
 }
 
@@ -3317,7 +3319,7 @@
 free_misc (misc)
      Lisp_Object misc;
 {
-  XMISC (misc)->u_marker.type = Lisp_Misc_Free;
+  XMISCTYPE (misc) = Lisp_Misc_Free;
   XMISC (misc)->u_free.chain = marker_free_list;
   marker_free_list = XMISC (misc);
 
@@ -4033,7 +4035,7 @@
 	      && offset < (MARKER_BLOCK_SIZE * sizeof b->markers[0])
 	      && (b != marker_block
 		  || offset / sizeof b->markers[0] < marker_block_index)
-	      && ((union Lisp_Misc *) p)->u_marker.type != Lisp_Misc_Free);
+	      && ((union Lisp_Misc *) p)->u_any.type != Lisp_Misc_Free);
     }
   else
     return 0;
@@ -4164,7 +4166,7 @@
 	  break;
 
 	case Lisp_Misc:
-	  mark_p = (live_misc_p (m, po) && !XMARKER (obj)->gcmarkbit);
+	  mark_p = (live_misc_p (m, po) && !XMISCANY (obj)->gcmarkbit);
 	  break;
 
 	case Lisp_Int:
@@ -5613,14 +5615,13 @@
 
     case Lisp_Misc:
       CHECK_ALLOCATED_AND_LIVE (live_misc_p);
-      if (XMARKER (obj)->gcmarkbit)
+      if (XMISCANY (obj)->gcmarkbit)
 	break;
-      XMARKER (obj)->gcmarkbit = 1;
+      XMISCANY (obj)->gcmarkbit = 1;
 
       switch (XMISCTYPE (obj))
 	{
 	case Lisp_Misc_Buffer_Local_Value:
-	case Lisp_Misc_Some_Buffer_Local_Value:
 	  {
 	    register struct Lisp_Buffer_Local_Value *ptr
 	      = XBUFFER_LOCAL_VALUE (obj);
@@ -5806,7 +5807,7 @@
       break;
 
     case Lisp_Misc:
-      survives_p = XMARKER (obj)->gcmarkbit;
+      survives_p = XMISCANY (obj)->gcmarkbit;
       break;
 
     case Lisp_String:
@@ -6103,9 +6104,9 @@
 
 	for (i = 0; i < lim; i++)
 	  {
-	    if (!mblk->markers[i].u_marker.gcmarkbit)
+	    if (!mblk->markers[i].u_any.gcmarkbit)
 	      {
-		if (mblk->markers[i].u_marker.type == Lisp_Misc_Marker)
+		if (mblk->markers[i].u_any.type == Lisp_Misc_Marker)
 		  unchain_marker (&mblk->markers[i].u_marker);
 		/* Set the type of the freed object to Lisp_Misc_Free.
 		   We could leave the type alone, since nobody checks it,
@@ -6118,7 +6119,7 @@
 	    else
 	      {
 		num_used++;
-		mblk->markers[i].u_marker.gcmarkbit = 0;
+		mblk->markers[i].u_any.gcmarkbit = 0;
 	      }
 	  }
 	lim = MARKER_BLOCK_SIZE;
@@ -6256,7 +6257,7 @@
      const char *file;
      int line;
 {
-  fprintf (stderr, "\r\nEmacs fatal error: %s:%d: %s\r\n",
+  fprintf (stderr, "\r\n%s:%d: Emacs fatal error: %s\r\n",
 	   file, line, msg);
   abort ();
 }
--- a/src/buffer.c	Mon Oct 15 15:43:53 2007 +0000
+++ b/src/buffer.c	Fri Oct 19 00:00:21 2007 +0000
@@ -362,8 +362,6 @@
 
   b = (struct buffer *) allocate_buffer ();
 
-  b->size = sizeof (struct buffer) / sizeof (EMACS_INT);
-
   /* An ordinary buffer uses its own struct buffer_text.  */
   b->text = &b->own_text;
   b->base_buffer = 0;
@@ -417,10 +415,7 @@
   STRING_SET_INTERVALS (name, NULL_INTERVAL);
   b->name = name;
 
-  if (SREF (name, 0) != ' ')
-    b->undo_list = Qnil;
-  else
-    b->undo_list = Qt;
+  b->undo_list = (SREF (name, 0) != ' ') ? Qnil : Qt;
 
   reset_buffer (b);
   reset_buffer_local_variables (b, 1);
@@ -430,7 +425,6 @@
   b->name = name;
 
   /* Put this in the alist of all live buffers.  */
-  XSETPVECTYPE (b, PVEC_BUFFER);
   XSETBUFFER (buf, b);
   Vbuffer_alist = nconc2 (Vbuffer_alist, Fcons (Fcons (name, buf), Qnil));
 
@@ -568,13 +562,10 @@
     error ("Empty string for buffer name is not allowed");
 
   b = (struct buffer *) allocate_buffer ();
-  b->size = sizeof (struct buffer) / sizeof (EMACS_INT);
-  XSETPVECTYPE (b, PVEC_BUFFER);
-
-  if (XBUFFER (base_buffer)->base_buffer)
-    b->base_buffer = XBUFFER (base_buffer)->base_buffer;
-  else
-    b->base_buffer = XBUFFER (base_buffer);
+
+  b->base_buffer = (XBUFFER (base_buffer)->base_buffer
+		    ? XBUFFER (base_buffer)->base_buffer
+		    : XBUFFER (base_buffer));
 
   /* Use the base buffer's text object.  */
   b->text = b->base_buffer->text;
@@ -1919,8 +1910,7 @@
   for (tail = b->local_var_alist; CONSP (tail); tail = XCDR (tail))
     {
       valcontents = SYMBOL_VALUE (XCAR (XCAR (tail)));
-      if ((BUFFER_LOCAL_VALUEP (valcontents)
-	   || SOME_BUFFER_LOCAL_VALUEP (valcontents))
+      if ((BUFFER_LOCAL_VALUEP (valcontents))
 	  && (tem = XBUFFER_LOCAL_VALUE (valcontents)->realvalue,
 	      (BOOLFWDP (tem) || INTFWDP (tem) || OBJFWDP (tem))))
 	/* Just reference the variable
@@ -1934,8 +1924,7 @@
     for (tail = old_buf->local_var_alist; CONSP (tail); tail = XCDR (tail))
       {
 	valcontents = SYMBOL_VALUE (XCAR (XCAR (tail)));
-	if ((BUFFER_LOCAL_VALUEP (valcontents)
-	     || SOME_BUFFER_LOCAL_VALUEP (valcontents))
+	if ((BUFFER_LOCAL_VALUEP (valcontents))
 	    && (tem = XBUFFER_LOCAL_VALUE (valcontents)->realvalue,
 		(BOOLFWDP (tem) || INTFWDP (tem) || OBJFWDP (tem))))
 	  /* Just reference the variable
@@ -2509,7 +2498,7 @@
   /* Any which are supposed to be permanent,
      make local again, with the same values they had.  */
 
-  for (alist = oalist; !NILP (alist); alist = XCDR (alist))
+  for (alist = oalist; CONSP (alist); alist = XCDR (alist))
     {
       sym = XCAR (XCAR (alist));
       tem = Fget (sym, Qpermanent_local);
@@ -2539,7 +2528,7 @@
   XSETBUFFER (buffer, b);
   oalist = b->local_var_alist;
 
-  for (alist = oalist; !NILP (alist); alist = XCDR (alist))
+  for (alist = oalist; CONSP (alist); alist = XCDR (alist))
     {
       sym = XCAR (XCAR (alist));
 
--- a/src/coding.c	Mon Oct 15 15:43:53 2007 +0000
+++ b/src/coding.c	Fri Oct 19 00:00:21 2007 +0000
@@ -329,6 +329,8 @@
 Lisp_Object Qinsufficient_source, Qinconsistent_eol, Qinvalid_source;
 Lisp_Object Qinterrupted, Qinsufficient_memory;
 
+extern Lisp_Object Qcompletion_ignore_case;
+
 /* If a symbol has this property, evaluate the value to define the
    symbol as a coding system.  */
 static Lisp_Object Qcoding_system_define_form;
@@ -7194,16 +7196,22 @@
 
 DEFUN ("read-coding-system", Fread_coding_system, Sread_coding_system, 1, 2, 0,
        doc: /* Read a coding system from the minibuffer, prompting with string PROMPT.
-If the user enters null input, return second argument DEFAULT-CODING-SYSTEM.  */)
+If the user enters null input, return second argument DEFAULT-CODING-SYSTEM.
+Ignores case when completing coding systems (all Emacs coding systems
+are lower-case).  */)
      (prompt, default_coding_system)
      Lisp_Object prompt, default_coding_system;
 {
   Lisp_Object val;
+  int count = SPECPDL_INDEX ();
+
   if (SYMBOLP (default_coding_system))
-    XSETSTRING (default_coding_system, XPNTR (SYMBOL_NAME (default_coding_system)));
+    default_coding_system = SYMBOL_NAME (default_coding_system);
+  specbind (Qcompletion_ignore_case, Qt);
   val = Fcompleting_read (prompt, Vcoding_system_alist, Qnil,
 			  Qt, Qnil, Qcoding_system_history,
 			  default_coding_system, Qnil);
+  unbind_to (count, Qnil);
   return (SCHARS (val) == 0 ? Qnil : Fintern (val, Qnil));
 }
 
--- a/src/config.in	Mon Oct 15 15:43:53 2007 +0000
+++ b/src/config.in	Fri Oct 19 00:00:21 2007 +0000
@@ -492,7 +492,7 @@
 /* Define to 1 if you have the `rename' function. */
 #undef HAVE_RENAME
 
-/* Define to 1 if you have the `res_init' function. */
+/* Define to 1 if res_init is available. */
 #undef HAVE_RES_INIT
 
 /* Define to 1 if you have the `rindex' function. */
--- a/src/data.c	Mon Oct 15 15:43:53 2007 +0000
+++ b/src/data.c	Fri Oct 19 00:00:21 2007 +0000
@@ -584,8 +584,7 @@
 
   valcontents = SYMBOL_VALUE (symbol);
 
-  if (BUFFER_LOCAL_VALUEP (valcontents)
-      || SOME_BUFFER_LOCAL_VALUEP (valcontents))
+  if (BUFFER_LOCAL_VALUEP (valcontents))
     valcontents = swap_in_symval_forwarding (symbol, valcontents);
 
   return (EQ (valcontents, Qunbound) ? Qnil : Qt);
@@ -998,8 +997,7 @@
     default:
     def:
       valcontents = SYMBOL_VALUE (symbol);
-      if (BUFFER_LOCAL_VALUEP (valcontents)
-	  || SOME_BUFFER_LOCAL_VALUEP (valcontents))
+      if (BUFFER_LOCAL_VALUEP (valcontents))
 	XBUFFER_LOCAL_VALUE (valcontents)->realvalue = newval;
       else
 	SET_SYMBOL_VALUE (symbol, newval);
@@ -1016,8 +1014,7 @@
   Lisp_Object valcontents, cdr;
 
   valcontents = SYMBOL_VALUE (symbol);
-  if (!BUFFER_LOCAL_VALUEP (valcontents)
-      && !SOME_BUFFER_LOCAL_VALUEP (valcontents))
+  if (!BUFFER_LOCAL_VALUEP (valcontents))
     abort ();
   cdr = XBUFFER_LOCAL_VALUE (valcontents)->cdr;
 
@@ -1106,8 +1103,7 @@
   CHECK_SYMBOL (symbol);
   valcontents = SYMBOL_VALUE (symbol);
 
-  if (BUFFER_LOCAL_VALUEP (valcontents)
-      || SOME_BUFFER_LOCAL_VALUEP (valcontents))
+  if (BUFFER_LOCAL_VALUEP (valcontents))
     valcontents = swap_in_symval_forwarding (symbol, valcontents);
 
   if (MISCP (valcontents))
@@ -1225,8 +1221,7 @@
 	  && !let_shadows_buffer_binding_p (symbol))
 	SET_PER_BUFFER_VALUE_P (buf, idx, 1);
     }
-  else if (BUFFER_LOCAL_VALUEP (valcontents)
-	   || SOME_BUFFER_LOCAL_VALUEP (valcontents))
+  else if (BUFFER_LOCAL_VALUEP (valcontents))
     {
       /* valcontents is a struct Lisp_Buffer_Local_Value.   */
       if (XSYMBOL (symbol)->indirect_variable)
@@ -1271,7 +1266,7 @@
 		 indicating that we're seeing the default value.
 		 Likewise if the variable has been let-bound
 		 in the current buffer.  */
-	      if (bindflag || SOME_BUFFER_LOCAL_VALUEP (valcontents)
+	      if (bindflag || !XBUFFER_LOCAL_VALUE (valcontents)->local_if_set
 		  || let_shadows_buffer_binding_p (symbol))
 		{
 		  XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 0;
@@ -1299,8 +1294,7 @@
 	    }
 
 	  /* Record which binding is now loaded.  */
-	  XSETCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr,
-		   tem1);
+	  XSETCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr, tem1);
 
 	  /* Set `buffer' and `frame' slots for the binding now loaded.  */
 	  XSETBUFFER (XBUFFER_LOCAL_VALUE (valcontents)->buffer, buf);
@@ -1319,8 +1313,7 @@
   /* If we just set a variable whose current binding is frame-local,
      store the new value in the frame parameter too.  */
 
-  if (BUFFER_LOCAL_VALUEP (valcontents)
-      || SOME_BUFFER_LOCAL_VALUEP (valcontents))
+  if (BUFFER_LOCAL_VALUEP (valcontents))
     {
       /* What binding is loaded right now?  */
       current_alist_element
@@ -1362,8 +1355,7 @@
     }
 
   /* Handle user-created local variables.  */
-  if (BUFFER_LOCAL_VALUEP (valcontents)
-      || SOME_BUFFER_LOCAL_VALUEP (valcontents))
+  if (BUFFER_LOCAL_VALUEP (valcontents))
     {
       /* If var is set up for a buffer that lacks a local value for it,
 	 the current value is nominally the default value.
@@ -1447,8 +1439,7 @@
       return value;
     }
 
-  if (!BUFFER_LOCAL_VALUEP (valcontents)
-      && !SOME_BUFFER_LOCAL_VALUEP (valcontents))
+  if (!BUFFER_LOCAL_VALUEP (valcontents))
     return Fset (symbol, value);
 
   /* Store new value into the DEFAULT-VALUE slot.  */
@@ -1533,27 +1524,28 @@
   if (EQ (variable, Qnil) || EQ (variable, Qt) || KBOARD_OBJFWDP (valcontents))
     error ("Symbol %s may not be buffer-local", SDATA (SYMBOL_NAME (variable)));
 
-  if (BUFFER_LOCAL_VALUEP (valcontents) || BUFFER_OBJFWDP (valcontents))
+  if (BUFFER_OBJFWDP (valcontents))
     return variable;
-  if (SOME_BUFFER_LOCAL_VALUEP (valcontents))
+  else if (BUFFER_LOCAL_VALUEP (valcontents))
+    newval = valcontents;
+  else
     {
-      XMISCTYPE (SYMBOL_VALUE (variable)) = Lisp_Misc_Buffer_Local_Value;
-      return variable;
+      if (EQ (valcontents, Qunbound))
+	SET_SYMBOL_VALUE (variable, Qnil);
+      tem = Fcons (Qnil, Fsymbol_value (variable));
+      XSETCAR (tem, tem);
+      newval = allocate_misc ();
+      XMISCTYPE (newval) = Lisp_Misc_Buffer_Local_Value;
+      XBUFFER_LOCAL_VALUE (newval)->realvalue = SYMBOL_VALUE (variable);
+      XBUFFER_LOCAL_VALUE (newval)->buffer = Fcurrent_buffer ();
+      XBUFFER_LOCAL_VALUE (newval)->frame = Qnil;
+      XBUFFER_LOCAL_VALUE (newval)->found_for_buffer = 0;
+      XBUFFER_LOCAL_VALUE (newval)->found_for_frame = 0;
+      XBUFFER_LOCAL_VALUE (newval)->check_frame = 0;
+      XBUFFER_LOCAL_VALUE (newval)->cdr = tem;
+      SET_SYMBOL_VALUE (variable, newval);
     }
-  if (EQ (valcontents, Qunbound))
-    SET_SYMBOL_VALUE (variable, Qnil);
-  tem = Fcons (Qnil, Fsymbol_value (variable));
-  XSETCAR (tem, tem);
-  newval = allocate_misc ();
-  XMISCTYPE (newval) = Lisp_Misc_Buffer_Local_Value;
-  XBUFFER_LOCAL_VALUE (newval)->realvalue = SYMBOL_VALUE (variable);
-  XBUFFER_LOCAL_VALUE (newval)->buffer = Fcurrent_buffer ();
-  XBUFFER_LOCAL_VALUE (newval)->frame = Qnil;
-  XBUFFER_LOCAL_VALUE (newval)->found_for_buffer = 0;
-  XBUFFER_LOCAL_VALUE (newval)->found_for_frame = 0;
-  XBUFFER_LOCAL_VALUE (newval)->check_frame = 0;
-  XBUFFER_LOCAL_VALUE (newval)->cdr = tem;
-  SET_SYMBOL_VALUE (variable, newval);
+  XBUFFER_LOCAL_VALUE (newval)->local_if_set = 1;
   return variable;
 }
 
@@ -1589,7 +1581,9 @@
   if (EQ (variable, Qnil) || EQ (variable, Qt) || KBOARD_OBJFWDP (valcontents))
     error ("Symbol %s may not be buffer-local", SDATA (SYMBOL_NAME (variable)));
 
-  if (BUFFER_LOCAL_VALUEP (valcontents) || BUFFER_OBJFWDP (valcontents))
+  if ((BUFFER_LOCAL_VALUEP (valcontents)
+       && XBUFFER_LOCAL_VALUE (valcontents)->local_if_set)
+      || BUFFER_OBJFWDP (valcontents))
     {
       tem = Fboundp (variable);
 
@@ -1599,16 +1593,17 @@
       return variable;
     }
   /* Make sure symbol is set up to hold per-buffer values.  */
-  if (!SOME_BUFFER_LOCAL_VALUEP (valcontents))
+  if (!BUFFER_LOCAL_VALUEP (valcontents))
     {
       Lisp_Object newval;
       tem = Fcons (Qnil, do_symval_forwarding (valcontents));
       XSETCAR (tem, tem);
       newval = allocate_misc ();
-      XMISCTYPE (newval) = Lisp_Misc_Some_Buffer_Local_Value;
+      XMISCTYPE (newval) = Lisp_Misc_Buffer_Local_Value;
       XBUFFER_LOCAL_VALUE (newval)->realvalue = SYMBOL_VALUE (variable);
       XBUFFER_LOCAL_VALUE (newval)->buffer = Qnil;
       XBUFFER_LOCAL_VALUE (newval)->frame = Qnil;
+      XBUFFER_LOCAL_VALUE (newval)->local_if_set = 0;
       XBUFFER_LOCAL_VALUE (newval)->found_for_buffer = 0;
       XBUFFER_LOCAL_VALUE (newval)->found_for_frame = 0;
       XBUFFER_LOCAL_VALUE (newval)->check_frame = 0;
@@ -1681,8 +1676,7 @@
       return variable;
     }
 
-  if (!BUFFER_LOCAL_VALUEP (valcontents)
-      && !SOME_BUFFER_LOCAL_VALUEP (valcontents))
+  if (!BUFFER_LOCAL_VALUEP (valcontents))
     return variable;
 
   /* Get rid of this buffer's alist element, if any.  */
@@ -1743,8 +1737,7 @@
       || BUFFER_OBJFWDP (valcontents))
     error ("Symbol %s may not be frame-local", SDATA (SYMBOL_NAME (variable)));
 
-  if (BUFFER_LOCAL_VALUEP (valcontents)
-      || SOME_BUFFER_LOCAL_VALUEP (valcontents))
+  if (BUFFER_LOCAL_VALUEP (valcontents))
     {
       XBUFFER_LOCAL_VALUE (valcontents)->check_frame = 1;
       return variable;
@@ -1755,10 +1748,11 @@
   tem = Fcons (Qnil, Fsymbol_value (variable));
   XSETCAR (tem, tem);
   newval = allocate_misc ();
-  XMISCTYPE (newval) = Lisp_Misc_Some_Buffer_Local_Value;
+  XMISCTYPE (newval) = Lisp_Misc_Buffer_Local_Value;
   XBUFFER_LOCAL_VALUE (newval)->realvalue = SYMBOL_VALUE (variable);
   XBUFFER_LOCAL_VALUE (newval)->buffer = Qnil;
   XBUFFER_LOCAL_VALUE (newval)->frame = Qnil;
+  XBUFFER_LOCAL_VALUE (newval)->local_if_set = 0;
   XBUFFER_LOCAL_VALUE (newval)->found_for_buffer = 0;
   XBUFFER_LOCAL_VALUE (newval)->found_for_frame = 0;
   XBUFFER_LOCAL_VALUE (newval)->check_frame = 1;
@@ -1789,8 +1783,7 @@
   variable = indirect_variable (variable);
 
   valcontents = SYMBOL_VALUE (variable);
-  if (BUFFER_LOCAL_VALUEP (valcontents)
-      || SOME_BUFFER_LOCAL_VALUEP (valcontents))
+  if (BUFFER_LOCAL_VALUEP (valcontents))
     {
       Lisp_Object tail, elt;
 
@@ -1838,15 +1831,14 @@
 
   valcontents = SYMBOL_VALUE (variable);
 
-  /* This means that make-variable-buffer-local was done.  */
-  if (BUFFER_LOCAL_VALUEP (valcontents))
+  if (BUFFER_OBJFWDP (valcontents))
+    /* All these slots become local if they are set.  */
     return Qt;
-  /* All these slots become local if they are set.  */
-  if (BUFFER_OBJFWDP (valcontents))
-    return Qt;
-  if (SOME_BUFFER_LOCAL_VALUEP (valcontents))
+  else if (BUFFER_LOCAL_VALUEP (valcontents))
     {
       Lisp_Object tail, elt;
+      if (XBUFFER_LOCAL_VALUE (valcontents)->local_if_set)
+	return Qt;
       for (tail = buf->local_var_alist; CONSP (tail); tail = XCDR (tail))
 	{
 	  elt = XCAR (tail);
@@ -1877,14 +1869,13 @@
   valcontents = XSYMBOL (variable)->value;
 
   if (BUFFER_LOCAL_VALUEP (valcontents)
-      || SOME_BUFFER_LOCAL_VALUEP (valcontents)
       || BUFFER_OBJFWDP (valcontents))
     {
       /* For a local variable, record both the symbol and which
 	 buffer's or frame's value we are saving.  */
       if (!NILP (Flocal_variable_p (variable, Qnil)))
 	return Fcurrent_buffer ();
-      else if (!BUFFER_OBJFWDP (valcontents)
+      else if (BUFFER_LOCAL_VALUEP (valcontents)
 	       && XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame)
 	return XBUFFER_LOCAL_VALUE (valcontents)->frame;
     }
--- a/src/dired.c	Mon Oct 15 15:43:53 2007 +0000
+++ b/src/dired.c	Fri Oct 19 00:00:21 2007 +0000
@@ -116,10 +116,10 @@
 #endif
 
 extern int completion_ignore_case;
+extern Lisp_Object Qcompletion_ignore_case;
 extern Lisp_Object Vcompletion_regexp_list;
 
 Lisp_Object Vcompletion_ignored_extensions;
-Lisp_Object Qcompletion_ignore_case;
 Lisp_Object Qdirectory_files;
 Lisp_Object Qdirectory_files_and_attributes;
 Lisp_Object Qfile_name_completion;
@@ -1078,11 +1078,6 @@
   defsubr (&Sfile_attributes);
   defsubr (&Sfile_attributes_lessp);
 
-#ifdef VMS
-  Qcompletion_ignore_case = intern ("completion-ignore-case");
-  staticpro (&Qcompletion_ignore_case);
-#endif /* VMS */
-
   DEFVAR_LISP ("completion-ignored-extensions", &Vcompletion_ignored_extensions,
 	       doc: /* Completion ignores file names ending in any string in this list.
 It does not ignore them if all possible completions end in one of
--- a/src/doc.c	Mon Oct 15 15:43:53 2007 +0000
+++ b/src/doc.c	Fri Oct 19 00:00:21 2007 +0000
@@ -693,15 +693,17 @@
               if (fromfile[len-1] == 'c')
                 fromfile[len-1] = 'o';
 
-              if (EQ (Fmember (build_string (fromfile), Vbuild_files), Qnil))
-                skip_file = 1;
-              else
-                skip_file = 0;
+	      skip_file = NILP (Fmember (build_string (fromfile),
+					 Vbuild_files));
             }
 
 	  sym = oblookup (Vobarray, p + 2,
 			  multibyte_chars_in_text (p + 2, end - p - 2),
 			  end - p - 2);
+	  /* Check skip_file so that when a function is defined several
+	     times in different files (typically, once in xterm, once in
+	     w32term, ...), we only pay attention to the one that
+	     matters.  */
 	  if (! skip_file && SYMBOLP (sym))
 	    {
 	      /* Attach a docstring to a variable?  */
--- a/src/eval.c	Mon Oct 15 15:43:53 2007 +0000
+++ b/src/eval.c	Fri Oct 19 00:00:21 2007 +0000
@@ -468,7 +468,7 @@
   struct gcpro gcpro1, gcpro2;
   register int argnum = 0;
 
-  if (NILP(args))
+  if (NILP (args))
     return Qnil;
 
   args_left = args;
@@ -1043,10 +1043,10 @@
   GCPRO2 (args, *temps);
   gcpro2.nvars = 0;
 
-  for (argnum = 0; !NILP (varlist); varlist = Fcdr (varlist))
+  for (argnum = 0; CONSP (varlist); varlist = XCDR (varlist))
     {
       QUIT;
-      elt = Fcar (varlist);
+      elt = XCAR (varlist);
       if (SYMBOLP (elt))
 	temps [argnum++] = Qnil;
       else if (! NILP (Fcdr (Fcdr (elt))))
@@ -1058,9 +1058,9 @@
   UNGCPRO;
 
   varlist = Fcar (args);
-  for (argnum = 0; !NILP (varlist); varlist = Fcdr (varlist))
+  for (argnum = 0; CONSP (varlist); varlist = XCDR (varlist))
     {
-      elt = Fcar (varlist);
+      elt = XCAR (varlist);
       tem = temps[argnum++];
       if (SYMBOLP (elt))
 	specbind (elt, tem);
@@ -3285,7 +3285,6 @@
       valcontents = XSYMBOL (symbol)->value;
 
       if (BUFFER_LOCAL_VALUEP (valcontents)
-	  || SOME_BUFFER_LOCAL_VALUEP (valcontents)
 	  || BUFFER_OBJFWDP (valcontents))
 	{
 	  Lisp_Object where, current_buffer;
@@ -3296,7 +3295,7 @@
 	     buffer's or frame's value we are saving.  */
 	  if (!NILP (Flocal_variable_p (symbol, Qnil)))
 	    where = current_buffer;
-	  else if (!BUFFER_OBJFWDP (valcontents)
+	  else if (BUFFER_LOCAL_VALUEP (valcontents)
 		   && XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame)
 	    where = XBUFFER_LOCAL_VALUE (valcontents)->frame;
 	  else
--- a/src/fileio.c	Mon Oct 15 15:43:53 2007 +0000
+++ b/src/fileio.c	Fri Oct 19 00:00:21 2007 +0000
@@ -6079,6 +6079,7 @@
 
 /* Reading and completing file names */
 extern Lisp_Object Ffile_name_completion (), Ffile_name_all_completions ();
+extern Lisp_Object Qcompletion_ignore_case;
 
 /* In the string VAL, change each $ to $$ and return the result.  */
 
@@ -6384,7 +6385,7 @@
     }
 
   count = SPECPDL_INDEX ();
-  specbind (intern ("completion-ignore-case"),
+  specbind (Qcompletion_ignore_case,
 	    read_file_name_completion_ignore_case ? Qt : Qnil);
   specbind (intern ("minibuffer-completing-file-name"), Qt);
   specbind (intern ("read-file-name-predicate"),
--- a/src/fns.c	Mon Oct 15 15:43:53 2007 +0000
+++ b/src/fns.c	Fri Oct 19 00:00:21 2007 +0000
@@ -1370,7 +1370,7 @@
      Lisp_Object list;
 {
   register Lisp_Object tail;
-  for (tail = list; !NILP (tail); tail = XCDR (tail))
+  for (tail = list; CONSP (tail); tail = XCDR (tail))
     {
       register Lisp_Object tem;
       CHECK_LIST_CONS (tail, list);
@@ -1421,7 +1421,7 @@
   if (!FLOATP (elt))
     return Fmemq (elt, list);
 
-  for (tail = list; !NILP (tail); tail = XCDR (tail))
+  for (tail = list; CONSP (tail); tail = XCDR (tail))
     {
       register Lisp_Object tem;
       CHECK_LIST_CONS (tail, list);
@@ -1741,7 +1741,7 @@
     {
       Lisp_Object tail, prev;
 
-      for (tail = seq, prev = Qnil; !NILP (tail); tail = XCDR (tail))
+      for (tail = seq, prev = Qnil; CONSP (tail); tail = XCDR (tail))
 	{
 	  CHECK_LIST_CONS (tail, seq);
 
--- a/src/frame.c	Mon Oct 15 15:43:53 2007 +0000
+++ b/src/frame.c	Fri Oct 19 00:00:21 2007 +0000
@@ -2299,8 +2299,7 @@
     {
       Lisp_Object valcontents;
       valcontents = SYMBOL_VALUE (prop);
-      if ((BUFFER_LOCAL_VALUEP (valcontents)
-  	   || SOME_BUFFER_LOCAL_VALUEP (valcontents))
+      if ((BUFFER_LOCAL_VALUEP (valcontents))
 	  && XBUFFER_LOCAL_VALUE (valcontents)->check_frame
 	  && XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame
  	  && XFRAME (XBUFFER_LOCAL_VALUE (valcontents)->frame) == f)
--- a/src/keyboard.c	Mon Oct 15 15:43:53 2007 +0000
+++ b/src/keyboard.c	Fri Oct 19 00:00:21 2007 +0000
@@ -8538,7 +8538,7 @@
 	     to indicate that they came from a mouse menu,
 	     so that when present in last_nonmenu_event
 	     they won't confuse things.  */
-	  for (tem = XCDR (value); !NILP (tem); tem = XCDR (tem))
+	  for (tem = XCDR (value); CONSP (tem); tem = XCDR (tem))
 	    {
 	      record_menu_key (XCAR (tem));
 	      if (SYMBOLP (XCAR (tem))
@@ -9185,13 +9185,16 @@
   orig_keymap = get_local_map (PT, current_buffer, Qkeymap);
   from_string = Qnil;
 
-  /* We jump here when the key sequence has been thoroughly changed, and
-     we need to rescan it starting from the beginning.  When we jump here,
-     keybuf[0..mock_input] holds the sequence we should reread.  */
- replay_sequence:
-
-  /* We may switch keyboards between rescans, so we need to
-     reinitialize fkey and keytran before each replay.  */
+  /* The multi-tty merge moved the code below to right after
+   `replay_sequence' which caused alll these translation maps to be applied
+   repeatedly, even tho their doc says very clearly they are not applied to
+   their own output.
+   The reason for this move was: "We may switch keyboards between rescans,
+   so we need to reinitialize fkey and keytran before each replay".
+   This move was wrong (even if we switch keyboards, keybuf still holds the
+   keys we've read already from the original keyboard and some of those keys
+   may have already been translated).  So there may still be a bug out there
+   lurking.  */
   indec.map = indec.parent = current_kboard->Vinput_decode_map;
   fkey.map = fkey.parent = current_kboard->Vlocal_function_key_map;
   keytran.map = keytran.parent = Vkey_translation_map;
@@ -9199,6 +9202,11 @@
   fkey.start = fkey.end = 0;
   keytran.start = keytran.end = 0;
 
+  /* We jump here when the key sequence has been thoroughly changed, and
+     we need to rescan it starting from the beginning.  When we jump here,
+     keybuf[0..mock_input] holds the sequence we should reread.  */
+ replay_sequence:
+
   starting_buffer = current_buffer;
   first_unbound = bufsize + 1;
 
--- a/src/keymap.c	Mon Oct 15 15:43:53 2007 +0000
+++ b/src/keymap.c	Fri Oct 19 00:00:21 2007 +0000
@@ -1280,9 +1280,9 @@
     {
       Lisp_Object maps, binding;
 
-      for (maps = keymaps; !NILP (maps); maps = Fcdr (maps))
+      for (maps = keymaps; CONSP (maps); maps = XCDR (maps))
 	{
-	  binding = Flookup_key (Fcar (maps), command_remapping_vector, Qnil);
+	  binding = Flookup_key (XCAR (maps), command_remapping_vector, Qnil);
 	  if (!NILP (binding) && !INTEGERP (binding))
 	    return binding;
 	}
@@ -2653,7 +2653,7 @@
       && !NILP (Fcommand_remapping (definition, Qnil, keymaps)))
     RETURN_UNGCPRO (Qnil);
 
-  for (; !NILP (maps); maps = Fcdr (maps))
+  for (; CONSP (maps); maps = XCDR (maps))
     {
       /* Key sequence to reach map, and the map that it reaches */
       register Lisp_Object this, map, tem;
@@ -2665,8 +2665,8 @@
       Lisp_Object last;
       int last_is_meta;
 
-      this = Fcar (Fcar (maps));
-      map  = Fcdr (Fcar (maps));
+      this = Fcar (XCAR (maps));
+      map  = Fcdr (XCAR (maps));
       last = make_number (XINT (Flength (this)) - 1);
       last_is_meta = (XINT (last) >= 0
 		      && EQ (Faref (this, last), meta_prefix_char));
@@ -3155,11 +3155,11 @@
       Lisp_Object list;
 
       /* Delete from MAPS each element that is for the menu bar.  */
-      for (list = maps; !NILP (list); list = XCDR (list))
+      for (list = maps; CONSP (list); list = XCDR (list))
 	{
 	  Lisp_Object elt, prefix, tem;
 
-	  elt = Fcar (list);
+	  elt = XCAR (list);
 	  prefix = Fcar (elt);
 	  if (XVECTOR (prefix)->size >= 1)
 	    {
@@ -3186,11 +3186,11 @@
       something = 1;
     }
 
-  for (; !NILP (maps); maps = Fcdr (maps))
+  for (; CONSP (maps); maps = XCDR (maps))
     {
       register Lisp_Object elt, prefix, tail;
 
-      elt = Fcar (maps);
+      elt = XCAR (maps);
       prefix = Fcar (elt);
 
       sub_shadows = Qnil;
--- a/src/lisp.h	Mon Oct 15 15:43:53 2007 +0000
+++ b/src/lisp.h	Fri Oct 19 00:00:21 2007 +0000
@@ -214,7 +214,6 @@
     Lisp_Misc_Objfwd,
     Lisp_Misc_Buffer_Objfwd,
     Lisp_Misc_Buffer_Local_Value,
-    Lisp_Misc_Some_Buffer_Local_Value,
     Lisp_Misc_Overlay,
     Lisp_Misc_Kboard_Objfwd,
     Lisp_Misc_Save_Value,
@@ -512,16 +511,20 @@
 /* Misc types.  */
 
 #define XMISC(a)   ((union Lisp_Misc *) XPNTR(a))
-#define XMISCTYPE(a)   (XMARKER (a)->type)
-#define XMARKER(a) (&(XMISC(a)->u_marker))
-#define XINTFWD(a) (&(XMISC(a)->u_intfwd))
-#define XBOOLFWD(a) (&(XMISC(a)->u_boolfwd))
-#define XOBJFWD(a) (&(XMISC(a)->u_objfwd))
-#define XBUFFER_OBJFWD(a) (&(XMISC(a)->u_buffer_objfwd))
-#define XBUFFER_LOCAL_VALUE(a) (&(XMISC(a)->u_buffer_local_value))
-#define XOVERLAY(a) (&(XMISC(a)->u_overlay))
-#define XKBOARD_OBJFWD(a) (&(XMISC(a)->u_kboard_objfwd))
-#define XSAVE_VALUE(a) (&(XMISC(a)->u_save_value))
+#define XMISCANY(a)	(eassert (MISCP (a)), &(XMISC(a)->u_any))
+#define XMISCTYPE(a)   (XMISCANY (a)->type)
+#define XMARKER(a)	(eassert (MARKERP (a)), &(XMISC(a)->u_marker))
+#define XINTFWD(a)	(eassert (INTFWDP (a)), &(XMISC(a)->u_intfwd))
+#define XBOOLFWD(a)	(eassert (BOOLFWDP (a)), &(XMISC(a)->u_boolfwd))
+#define XOBJFWD(a)	(eassert (OBJFWDP (a)), &(XMISC(a)->u_objfwd))
+#define XOVERLAY(a)	(eassert (OVERLAYP (a)), &(XMISC(a)->u_overlay))
+#define XSAVE_VALUE(a)	(eassert (SAVE_VALUEP (a)), &(XMISC(a)->u_save_value))
+#define XBUFFER_OBJFWD(a) \
+  (eassert (BUFFER_OBJFWDP (a)), &(XMISC(a)->u_buffer_objfwd))
+#define XBUFFER_LOCAL_VALUE(a) \
+  (eassert (BUFFER_LOCAL_VALUEP (a)), &(XMISC(a)->u_buffer_local_value))
+#define XKBOARD_OBJFWD(a) \
+  (eassert (KBOARD_OBJFWDP (a)), &(XMISC(a)->u_kboard_objfwd))
 
 /* Pseudovector types.  */
 
@@ -1108,6 +1111,13 @@
 
 /* These structures are used for various misc types.  */
 
+struct Lisp_Misc_Any		/* Supertype of all Misc types.  */
+{
+  int type : 16;		/* = Lisp_Misc_Marker */
+  unsigned gcmarkbit : 1;
+  int spacer : 15;
+};
+
 struct Lisp_Marker
 {
   int type : 16;		/* = Lisp_Misc_Marker */
@@ -1208,19 +1218,19 @@
    binding into `realvalue' (or through it).  Also update
    LOADED-BINDING to point to the newly loaded binding.
 
-   Lisp_Misc_Buffer_Local_Value and Lisp_Misc_Some_Buffer_Local_Value
-   both use this kind of structure.  With the former, merely setting
-   the variable creates a local binding for the current buffer.  With
-   the latter, setting the variable does not do that; only
-   make-local-variable does that.  */
+   `local_if_set' indicates that merely setting the variable creates a local
+   binding for the current buffer.  Otherwise the latter, setting the
+   variable does not do that; only make-local-variable does that.  */
 
 struct Lisp_Buffer_Local_Value
   {
-    int type : 16;      /* = Lisp_Misc_Buffer_Local_Value
-			   or Lisp_Misc_Some_Buffer_Local_Value */
+    int type : 16;      /* = Lisp_Misc_Buffer_Local_Value  */
     unsigned gcmarkbit : 1;
-    int spacer : 12;
-
+    int spacer : 11;
+
+    /* 1 means that merely setting the variable creates a local
+       binding for the current buffer */
+    unsigned int local_if_set : 1;
     /* 1 means this variable is allowed to have frame-local bindings,
        so check for them when looking for the proper binding.  */
     unsigned int check_frame : 1;
@@ -1310,7 +1320,8 @@
 
 union Lisp_Misc
   {
-    struct Lisp_Free u_free;
+    struct Lisp_Misc_Any u_any;	   /* Supertype of all Misc types.  */
+    struct Lisp_Free u_free;	   /* Includes padding to force alignment.  */
     struct Lisp_Marker u_marker;
     struct Lisp_Intfwd u_intfwd;
     struct Lisp_Boolfwd u_boolfwd;
@@ -1452,8 +1463,17 @@
 #define OBJFWDP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Objfwd)
 #define BUFFER_OBJFWDP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Buffer_Objfwd)
 #define BUFFER_LOCAL_VALUEP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Buffer_Local_Value)
+<<<<<<< TREE
 #define SOME_BUFFER_LOCAL_VALUEP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Some_Buffer_Local_Value)
+=======
+#define GC_BUFFER_LOCAL_VALUEP(x) (GC_MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Buffer_Local_Value)
+>>>>>>> MERGE-SOURCE
 #define KBOARD_OBJFWDP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Kboard_Objfwd)
+<<<<<<< TREE
+=======
+#define GC_KBOARD_OBJFWDP(x) (GC_MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Kboard_Objfwd)
+#define SAVE_VALUEP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Save_Value)
+>>>>>>> MERGE-SOURCE
 
 
 /* True if object X is a pseudovector whose code is CODE.  */
--- a/src/lread.c	Mon Oct 15 15:43:53 2007 +0000
+++ b/src/lread.c	Fri Oct 19 00:00:21 2007 +0000
@@ -1299,7 +1299,7 @@
 {
 #ifndef WINDOWSNT
   Lisp_Object tail;
-  for (tail = load_descriptor_list; !NILP (tail); tail = XCDR (tail))
+  for (tail = load_descriptor_list; CONSP (tail); tail = XCDR (tail))
     emacs_close (XFASTINT (XCAR (tail)));
 #endif
 }
--- a/src/macfns.c	Mon Oct 15 15:43:53 2007 +0000
+++ b/src/macfns.c	Fri Oct 19 00:00:21 2007 +0000
@@ -2826,7 +2826,7 @@
 
   /* All remaining specified parameters, which have not been "used"
      by x_get_arg and friends, now go in the misc. alist of the frame.  */
-  for (tem = parameters; !NILP (tem); tem = XCDR (tem))
+  for (tem = parameters; CONSP (tem); tem = XCDR (tem))
     if (CONSP (XCAR (tem)) && !NILP (XCAR (XCAR (tem))))
       f->param_alist = Fcons (XCAR (tem), f->param_alist);
 
@@ -3402,7 +3402,7 @@
   Lisp_Object tail, result;
 
   result = Qnil;
-  for (tail = x_display_name_list; ! NILP (tail); tail = XCDR (tail))
+  for (tail = x_display_name_list; CONSP (tail); tail = XCDR (tail))
     result = Fcons (XCAR (XCAR (tail)), result);
 
   return result;
--- a/src/macselect.c	Mon Oct 15 15:43:53 2007 +0000
+++ b/src/macselect.c	Fri Oct 19 00:00:21 2007 +0000
@@ -487,7 +487,7 @@
     if (!NILP (prev_value))
       {
 	Lisp_Object rest;	/* we know it's not the CAR, so it's easy.  */
-	for (rest = Vselection_alist; !NILP (rest); rest = Fcdr (rest))
+	for (rest = Vselection_alist; CONSP (rest); rest = XCDR (rest))
 	  if (EQ (prev_value, Fcar (XCDR (rest))))
 	    {
 	      XSETCDR (rest, Fcdr (XCDR (rest)));
@@ -619,7 +619,7 @@
     }
 
   /* Delete elements after the beginning of Vselection_alist.  */
-  for (rest = Vselection_alist; !NILP (rest); rest = Fcdr (rest))
+  for (rest = Vselection_alist; CONSP (rest); rest = XCDR (rest))
     if (EQ (frame, Fcar (Fcdr (Fcdr (Fcdr (Fcar (XCDR (rest))))))))
       {
 	/* Let random Lisp code notice that the selection has been stolen.  */
@@ -762,7 +762,7 @@
   else
     {
       Lisp_Object rest;
-      for (rest = Vselection_alist; !NILP (rest); rest = Fcdr (rest))
+      for (rest = Vselection_alist; CONSP (rest); rest = XCDR (rest))
 	if (EQ (local_selection_data, Fcar (XCDR (rest))))
 	  {
 	    XSETCDR (rest, Fcdr (XCDR (rest)));
--- a/src/macterm.c	Mon Oct 15 15:43:53 2007 +0000
+++ b/src/macterm.c	Fri Oct 19 00:00:21 2007 +0000
@@ -8300,7 +8300,7 @@
 	  Lisp_Object rest = XCDR (XCDR (text_encoding_info));
 
 	  if (size > 0 || style == normal)
-	    for (; !NILP (rest); rest = XCDR (rest))
+	    for (; CONSP (rest); rest = XCDR (rest))
 	      add_mac_font_name (name, size, style, SDATA (XCAR (rest)));
 	}
     }
@@ -8375,7 +8375,7 @@
 		{
 		  Lisp_Object rest = XCDR (XCDR (text_encoding_info));
 
-		  for (; !NILP (rest); rest = XCDR (rest))
+		  for (; CONSP (rest); rest = XCDR (rest))
 		    add_mac_font_name (name, assc_entry->fontSize,
 				       assc_entry->fontStyle,
 				       SDATA (XCAR (rest)));
--- a/src/minibuf.c	Mon Oct 15 15:43:53 2007 +0000
+++ b/src/minibuf.c	Fri Oct 19 00:00:21 2007 +0000
@@ -118,6 +118,7 @@
 /* Nonzero means completion ignores case.  */
 
 int completion_ignore_case;
+Lisp_Object Qcompletion_ignore_case;
 
 /* List of regexps that should restrict possible completions.  */
 
@@ -2109,10 +2110,10 @@
   if (SYMBOLP (key))
     key = Fsymbol_name (key);
 
-  for (tail = list; !NILP (tail); tail = Fcdr (tail))
+  for (tail = list; CONSP (tail); tail = XCDR (tail))
     {
       register Lisp_Object elt, tem, thiscar;
-      elt = Fcar (tail);
+      elt = XCAR (tail);
       thiscar = CONSP (elt) ? XCAR (elt) : elt;
       if (SYMBOLP (thiscar))
 	thiscar = Fsymbol_name (thiscar);
@@ -2822,6 +2823,9 @@
   minibuf_save_list = Qnil;
   staticpro (&minibuf_save_list);
 
+  Qcompletion_ignore_case = intern ("completion-ignore-case");
+  staticpro (&Qcompletion_ignore_case);
+
   Qread_file_name_internal = intern ("read-file-name-internal");
   staticpro (&Qread_file_name_internal);
 
--- a/src/print.c	Mon Oct 15 15:43:53 2007 +0000
+++ b/src/print.c	Fri Oct 19 00:00:21 2007 +0000
@@ -2243,10 +2243,8 @@
 
 	case Lisp_Misc_Buffer_Local_Value:
 	  strout ("#<buffer_local_value ", -1, -1, printcharfun, 0);
-	  goto do_buffer_local;
-	case Lisp_Misc_Some_Buffer_Local_Value:
-	  strout ("#<some_buffer_local_value ", -1, -1, printcharfun, 0);
-	do_buffer_local:
+	  if (XBUFFER_LOCAL_VALUE (obj)->local_if_set)
+	    strout ("[local-if-set] ", -1, -1, printcharfun, 0);
 	  strout ("[realvalue] ", -1, -1, printcharfun, 0);
 	  print_object (XBUFFER_LOCAL_VALUE (obj)->realvalue,
 			printcharfun, escapeflag);
--- a/src/process.c	Mon Oct 15 15:43:53 2007 +0000
+++ b/src/process.c	Fri Oct 19 00:00:21 2007 +0000
@@ -121,6 +121,12 @@
 #include <sys/wait.h>
 #endif
 
+#ifdef HAVE_RES_INIT
+#include <netinet/in.h>
+#include <arpa/nameser.h>
+#include <resolv.h>
+#endif
+
 #include "lisp.h"
 #include "systime.h"
 #include "systty.h"
@@ -732,9 +738,9 @@
   buf = Fget_buffer (buffer);
   if (NILP (buf)) return Qnil;
 
-  for (tail = Vprocess_alist; !NILP (tail); tail = Fcdr (tail))
+  for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail))
     {
-      proc = Fcdr (Fcar (tail));
+      proc = Fcdr (XCAR (tail));
       if (PROCESSP (proc) && EQ (XPROCESS (proc)->buffer, buf))
 	return proc;
     }
@@ -1338,11 +1344,11 @@
   w_buffer = 6;  /* Buffer */
   w_tty = 0;     /* Omit if no ttys */
 
-  for (tail = Vprocess_alist; !NILP (tail); tail = Fcdr (tail))
+  for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail))
     {
       int i;
 
-      proc = Fcdr (Fcar (tail));
+      proc = Fcdr (XCAR (tail));
       p = XPROCESS (proc);
       if (NILP (p->childp))
 	continue;
@@ -1401,11 +1407,11 @@
   Findent_to (i_command, minspace); write_string ("-------", -1);
   write_string ("\n", -1);
 
-  for (tail = Vprocess_alist; !NILP (tail); tail = Fcdr (tail))
+  for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail))
     {
       Lisp_Object symbol;
 
-      proc = Fcdr (Fcar (tail));
+      proc = Fcdr (XCAR (tail));
       p = XPROCESS (proc);
       if (NILP (p->childp))
 	continue;
@@ -3082,6 +3088,11 @@
       hints.ai_family = family;
       hints.ai_socktype = socktype;
       hints.ai_protocol = 0;
+
+#ifdef HAVE_RES_INIT
+      res_init ();
+#endif
+
       ret = getaddrinfo (SDATA (host), portstring, &hints, &res);
       if (ret)
 #ifdef HAVE_GAI_STRERROR
@@ -3127,6 +3138,11 @@
 	 as it may `hang' Emacs for a very long time.  */
       immediate_quit = 1;
       QUIT;
+
+#ifdef HAVE_RES_INIT
+      res_init ();
+#endif
+
       host_info_ptr = gethostbyname (SDATA (host));
       immediate_quit = 0;
 
@@ -6689,12 +6705,12 @@
      that we run, we get called again to handle their status changes.  */
   update_tick = process_tick;
 
-  for (tail = Vprocess_alist; !NILP (tail); tail = Fcdr (tail))
+  for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail))
     {
       Lisp_Object symbol;
       register struct Lisp_Process *p;
 
-      proc = Fcdr (Fcar (tail));
+      proc = Fcdr (XCAR (tail));
       p = XPROCESS (proc);
 
       if (p->tick != p->update_tick)
--- a/src/textprop.c	Mon Oct 15 15:43:53 2007 +0000
+++ b/src/textprop.c	Fri Oct 19 00:00:21 2007 +0000
@@ -201,9 +201,9 @@
     {
       register int i;
       register Lisp_Object tail;
-      for (i = 0, tail = list; !NILP (tail); i++)
+      for (i = 0, tail = list; CONSP (tail); i++)
 	{
-	  tail = Fcdr (tail);
+	  tail = XCDR (tail);
 	  QUIT;
 	}
       if (i & 1)
@@ -226,18 +226,18 @@
   register int found;
 
   /* Go through each element of PLIST.  */
-  for (tail1 = plist; ! NILP (tail1); tail1 = Fcdr (Fcdr (tail1)))
+  for (tail1 = plist; CONSP (tail1); tail1 = Fcdr (XCDR (tail1)))
     {
-      sym1 = Fcar (tail1);
+      sym1 = XCAR (tail1);
       found = 0;
 
       /* Go through I's plist, looking for sym1 */
-      for (tail2 = i->plist; ! NILP (tail2); tail2 = Fcdr (Fcdr (tail2)))
-	if (EQ (sym1, Fcar (tail2)))
+      for (tail2 = i->plist; CONSP (tail2); tail2 = Fcdr (XCDR (tail2)))
+	if (EQ (sym1, XCAR (tail2)))
 	  {
 	    /* Found the same property on both lists.  If the
 	       values are unequal, return zero.  */
-	    if (! EQ (Fcar (Fcdr (tail1)), Fcar (Fcdr (tail2))))
+	    if (! EQ (Fcar (XCDR (tail1)), Fcar (XCDR (tail2))))
 	      return 0;
 
 	    /* Property has same value on both lists;  go to next one.  */
@@ -263,13 +263,13 @@
   register Lisp_Object tail1, tail2, sym;
 
   /* Go through each element of PLIST.  */
-  for (tail1 = plist; ! NILP (tail1); tail1 = Fcdr (Fcdr (tail1)))
+  for (tail1 = plist; CONSP (tail1); tail1 = Fcdr (XCDR (tail1)))
     {
-      sym = Fcar (tail1);
+      sym = XCAR (tail1);
 
       /* Go through i's plist, looking for tail1 */
-      for (tail2 = i->plist; ! NILP (tail2); tail2 = Fcdr (Fcdr (tail2)))
-	if (EQ (sym, Fcar (tail2)))
+      for (tail2 = i->plist; CONSP (tail2); tail2 = Fcdr (XCDR (tail2)))
+	if (EQ (sym, XCAR (tail2)))
 	  return 1;
     }
 
@@ -287,12 +287,12 @@
   register Lisp_Object tail1, tail2, sym;
 
   /* Go through each element of LIST.  */
-  for (tail1 = list; ! NILP (tail1); tail1 = XCDR (tail1))
+  for (tail1 = list; CONSP (tail1); tail1 = XCDR (tail1))
     {
       sym = Fcar (tail1);
 
       /* Go through i's plist, looking for tail1 */
-      for (tail2 = i->plist; ! NILP (tail2); tail2 = XCDR (XCDR (tail2)))
+      for (tail2 = i->plist; CONSP (tail2); tail2 = XCDR (XCDR (tail2)))
 	if (EQ (sym, XCAR (tail2)))
 	  return 1;
     }
@@ -391,21 +391,21 @@
   GCPRO3 (tail1, sym1, val1);
 
   /* Go through each element of PLIST.  */
-  for (tail1 = plist; ! NILP (tail1); tail1 = Fcdr (Fcdr (tail1)))
+  for (tail1 = plist; CONSP (tail1); tail1 = Fcdr (XCDR (tail1)))
     {
-      sym1 = Fcar (tail1);
-      val1 = Fcar (Fcdr (tail1));
+      sym1 = XCAR (tail1);
+      val1 = Fcar (XCDR (tail1));
       found = 0;
 
       /* Go through I's plist, looking for sym1 */
-      for (tail2 = i->plist; ! NILP (tail2); tail2 = Fcdr (Fcdr (tail2)))
-	if (EQ (sym1, Fcar (tail2)))
+      for (tail2 = i->plist; CONSP (tail2); tail2 = Fcdr (XCDR (tail2)))
+	if (EQ (sym1, XCAR (tail2)))
 	  {
 	    /* No need to gcpro, because tail2 protects this
 	       and it must be a cons cell (we get an error otherwise).  */
 	    register Lisp_Object this_cdr;
 
-	    this_cdr = Fcdr (tail2);
+	    this_cdr = XCDR (tail2);
 	    /* Found the property.  Now check its value.  */
 	    found = 1;
 
@@ -1965,10 +1965,10 @@
 	  plist = i->plist;
 
 	  if (!NILP (prop))
-	    for (; !NILP (plist); plist = Fcdr (Fcdr (plist)))
-	      if (EQ (Fcar (plist), prop))
+	    for (; CONSP (plist); plist = Fcdr (XCDR (plist)))
+	      if (EQ (XCAR (plist), prop))
 		{
-		  plist = Fcons (prop, Fcons (Fcar (Fcdr (plist)), Qnil));
+		  plist = Fcons (prop, Fcons (Fcar (XCDR (plist)), Qnil));
 		  break;
 		}
 
--- a/src/w32fns.c	Mon Oct 15 15:43:53 2007 +0000
+++ b/src/w32fns.c	Fri Oct 19 00:00:21 2007 +0000
@@ -850,11 +850,11 @@
 
   BLOCK_INPUT;
 
-  for (tail = Vw32_color_map; !NILP (tail); tail = Fcdr (tail))
+  for (tail = Vw32_color_map; CONSP (tail); tail = XCDR (tail))
     {
       register Lisp_Object elt, tem;
 
-      elt = Fcar (tail);
+      elt = XCAR (tail);
       if (!CONSP (elt)) continue;
 
       tem = Fcar (elt);
@@ -4506,7 +4506,7 @@
 
   /* All remaining specified parameters, which have not been "used"
      by x_get_arg and friends, now go in the misc. alist of the frame.  */
-  for (tem = parameters; !NILP (tem); tem = XCDR (tem))
+  for (tem = parameters; CONSP (tem); tem = XCDR (tem))
     if (CONSP (XCAR (tem)) && !NILP (XCAR (XCAR (tem))))
       f->param_alist = Fcons (XCAR (tem), f->param_alist);
 
@@ -6958,7 +6958,7 @@
   Lisp_Object tail, result;
 
   result = Qnil;
-  for (tail = w32_display_name_list; ! NILP (tail); tail = XCDR (tail))
+  for (tail = w32_display_name_list; CONSP (tail); tail = XCDR (tail))
     result = Fcons (XCAR (XCAR (tail)), result);
 
   return result;
--- a/src/w32menu.c	Mon Oct 15 15:43:53 2007 +0000
+++ b/src/w32menu.c	Fri Oct 19 00:00:21 2007 +0000
@@ -568,10 +568,10 @@
 
   init_menu_items ();
 
-  for (tail = menu; !NILP (tail); tail = Fcdr (tail))
+  for (tail = menu; CONSP (tail); tail = XCDR (tail))
     {
       Lisp_Object elt, pane_name, pane_data;
-      elt = Fcar (tail);
+      elt = XCAR (tail);
       pane_name = Fcar (elt);
       CHECK_STRING (pane_name);
       push_menu_pane (pane_name, Qnil);
@@ -591,9 +591,9 @@
 {
   Lisp_Object tail, item, item1;
 
-  for (tail = pane; !NILP (tail); tail = Fcdr (tail))
+  for (tail = pane; CONSP (tail); tail = XCDR (tail))
     {
-      item = Fcar (tail);
+      item = XCAR (tail);
       if (STRINGP (item))
 	push_menu_item (item, Qnil, Qnil, Qt, Qnil, Qnil, Qnil, Qnil);
       else if (NILP (item))
--- a/src/window.c	Mon Oct 15 15:43:53 2007 +0000
+++ b/src/window.c	Fri Oct 19 00:00:21 2007 +0000
@@ -2670,12 +2670,12 @@
 	{
 	  Lisp_Object child;
 
-	  for (child = w->prev; !NILP (child); child = XWINDOW (child)->prev)
+	  for (child = w->prev; WINDOWP (child); child = XWINDOW (child)->prev)
 	    if (!window_fixed_size_p (XWINDOW (child), width_p, 0))
 	      break;
 
 	  if (NILP (child))
-	    for (child = w->next; !NILP (child); child = XWINDOW (child)->next)
+	    for (child = w->next; WINDOWP (child); child = XWINDOW (child)->next)
 	      if (!window_fixed_size_p (XWINDOW (child), width_p, 0))
 		break;
 
@@ -4291,10 +4291,10 @@
 
   /* Find the total we can get from other siblings without deleting them.  */
   maximum = 0;
-  for (next = p->next; ! NILP (next); next = XWINDOW (next)->next)
+  for (next = p->next; WINDOWP (next); next = XWINDOW (next)->next)
     maximum += (*sizefun) (next) - window_min_size (XWINDOW (next),
 						    horiz_flag, 0, 0);
-  for (prev = p->prev; ! NILP (prev); prev = XWINDOW (prev)->prev)
+  for (prev = p->prev; WINDOWP (prev); prev = XWINDOW (prev)->prev)
     maximum += (*sizefun) (prev) - window_min_size (XWINDOW (prev),
 						    horiz_flag, 0, 0);
 
@@ -4442,10 +4442,10 @@
 	  Lisp_Object s;
 	  int n = 1;
 
-	  for (s = w->next; !NILP (s); s = XWINDOW (s)->next)
+	  for (s = w->next; WINDOWP (s); s = XWINDOW (s)->next)
 	    if (!window_fixed_size_p (XWINDOW (s), horiz_flag, 0))
 	      ++n;
-	  for (s = w->prev; !NILP (s); s = XWINDOW (s)->prev)
+	  for (s = w->prev; WINDOWP (s); s = XWINDOW (s)->prev)
 	    if (!window_fixed_size_p (XWINDOW (s), horiz_flag, 0))
 	      ++n;
 
@@ -4701,7 +4701,7 @@
       /* Find the last child.  We are taking space from lowest windows
 	 first, so we iterate over children from the last child
 	 backwards.  */
-      for (child = w->vchild; !NILP (child); child = XWINDOW (child)->next)
+      for (child = w->vchild; WINDOWP (child); child = XWINDOW (child)->next)
 	last_child = child;
 
       /* Assign new heights.  We leave only MIN_SAFE_WINDOW_HEIGHT.  */
--- a/src/xdisp.c	Mon Oct 15 15:43:53 2007 +0000
+++ b/src/xdisp.c	Fri Oct 19 00:00:21 2007 +0000
@@ -3844,7 +3844,13 @@
 	{
 	  if (handle_single_display_spec (it, XCAR (prop), object,
 					  position, display_replaced_p))
-	    display_replaced_p = 1;
+	    {
+	      display_replaced_p = 1;
+	      /* If some text in a string is replaced, `position' no
+		 longer points to the position of `object'.  */
+	      if (STRINGP (object))
+		break;
+	    }
 	}
     }
   else if (VECTORP (prop))
@@ -3853,7 +3859,13 @@
       for (i = 0; i < ASIZE (prop); ++i)
 	if (handle_single_display_spec (it, AREF (prop, i), object,
 					position, display_replaced_p))
-	  display_replaced_p = 1;
+	  {
+	    display_replaced_p = 1;
+	    /* If some text in a string is replaced, `position' no
+	       longer points to the position of `object'.  */
+	    if (STRINGP (object))
+	      break;
+	  }
     }
   else
     {
@@ -4242,13 +4254,16 @@
 	  /* Say that we haven't consumed the characters with
 	     `display' property yet.  The call to pop_it in
 	     set_iterator_to_next will clean this up.  */
-	  *position = start_pos;
+	  if (BUFFERP (object))
+	    it->current.pos = start_pos;
 	}
       else if (CONSP (value) && EQ (XCAR (value), Qspace))
 	{
 	  it->method = GET_FROM_STRETCH;
 	  it->object = value;
-	  *position = it->position = start_pos;
+	  it->position = start_pos;
+	  if (BUFFERP (object))
+	    it->current.pos = start_pos;
 	}
 #ifdef HAVE_WINDOW_SYSTEM
       else
@@ -4262,7 +4277,8 @@
 	  /* Say that we haven't consumed the characters with
 	     `display' property yet.  The call to pop_it in
 	     set_iterator_to_next will clean this up.  */
-	  *position = start_pos;
+	  if (BUFFERP (object))
+	    it->current.pos = start_pos;
 	}
 #endif /* HAVE_WINDOW_SYSTEM */
 
@@ -10972,8 +10988,7 @@
 	    SYMBOLP (sym))
 	&& (sym = indirect_variable (sym),
 	    val = SYMBOL_VALUE (sym),
-	    (BUFFER_LOCAL_VALUEP (val)
-	     || SOME_BUFFER_LOCAL_VALUEP (val)))
+	    (BUFFER_LOCAL_VALUEP (val)))
 	&& XBUFFER_LOCAL_VALUE (val)->check_frame)
       /* Use find_symbol_value rather than Fsymbol_value
 	 to avoid an error if it is void.  */
@@ -10985,8 +11000,7 @@
 	    SYMBOLP (sym))
 	&& (sym = indirect_variable (sym),
 	    val = SYMBOL_VALUE (sym),
-	    (BUFFER_LOCAL_VALUEP (val)
-	     || SOME_BUFFER_LOCAL_VALUEP (val)))
+	    (BUFFER_LOCAL_VALUEP (val)))
 	&& XBUFFER_LOCAL_VALUE (val)->check_frame)
       find_symbol_value (sym);
 }
--- a/src/xfns.c	Mon Oct 15 15:43:53 2007 +0000
+++ b/src/xfns.c	Fri Oct 19 00:00:21 2007 +0000
@@ -3675,7 +3675,7 @@
 
   /* All remaining specified parameters, which have not been "used"
      by x_get_arg and friends, now go in the misc. alist of the frame.  */
-  for (tem = parms; !NILP (tem); tem = XCDR (tem))
+  for (tem = parms; CONSP (tem); tem = XCDR (tem))
     if (CONSP (XCAR (tem)) && !NILP (XCAR (XCAR (tem))))
       f->param_alist = Fcons (XCAR (tem), f->param_alist);
 
@@ -4363,7 +4363,7 @@
   Lisp_Object tail, result;
 
   result = Qnil;
-  for (tail = x_display_name_list; ! NILP (tail); tail = XCDR (tail))
+  for (tail = x_display_name_list; CONSP (tail); tail = XCDR (tail))
     result = Fcons (XCAR (XCAR (tail)), result);
 
   return result;
--- a/src/xselect.c	Mon Oct 15 15:43:53 2007 +0000
+++ b/src/xselect.c	Fri Oct 19 00:00:21 2007 +0000
@@ -442,7 +442,7 @@
     if (!NILP (prev_value))
       {
 	Lisp_Object rest;	/* we know it's not the CAR, so it's easy.  */
-	for (rest = Vselection_alist; !NILP (rest); rest = Fcdr (rest))
+	for (rest = Vselection_alist; CONSP (rest); rest = XCDR (rest))
 	  if (EQ (prev_value, Fcar (XCDR (rest))))
 	    {
 	      XSETCDR (rest, Fcdr (XCDR (rest)));
@@ -1072,7 +1072,7 @@
   else
     {
       Lisp_Object rest;
-      for (rest = Vselection_alist; !NILP (rest); rest = Fcdr (rest))
+      for (rest = Vselection_alist; CONSP (rest); rest = XCDR (rest))
 	if (EQ (local_selection_data, Fcar (XCDR (rest))))
 	  {
 	    XSETCDR (rest, Fcdr (XCDR (rest)));
@@ -1153,7 +1153,7 @@
     }
 
   /* Delete elements after the beginning of Vselection_alist.  */
-  for (rest = Vselection_alist; !NILP (rest); rest = Fcdr (rest))
+  for (rest = Vselection_alist; CONSP (rest); rest = XCDR (rest))
     if (EQ (frame, Fcar (Fcdr (Fcdr (Fcdr (Fcar (XCDR (rest))))))))
       {
 	/* Let random Lisp code notice that the selection has been stolen.  */