changeset 108760:f528b6459bdd

merge trunk
author Kenichi Handa <handa@etlken>
date Tue, 25 May 2010 09:35:50 +0900
parents 0bb727f1d547 (current diff) 3f667e9ab359 (diff)
children 271da7ed4e2e
files src/ChangeLog src/dispextern.h src/xdisp.c
diffstat 80 files changed, 2111 insertions(+), 1283 deletions(-) [+]
line wrap: on
line diff
--- a/.bzrignore	Tue May 25 09:32:24 2010 +0900
+++ b/.bzrignore	Tue May 25 09:35:50 2010 +0900
@@ -68,3 +68,4 @@
 conftest*
 confdefs.h
 core
+lib-src/stamp-*
--- a/ChangeLog	Tue May 25 09:32:24 2010 +0900
+++ b/ChangeLog	Tue May 25 09:35:50 2010 +0900
@@ -1,3 +1,40 @@
+2010-05-24  Romain Francoise  <romain@orebokech.com>
+
+	* make-dist: Look for version in src/emacs.c.
+	Use lisp/subr.el rather than lisp/version.el for location check.
+
+2010-05-21  Glenn Morris  <rgm@gnu.org>
+
+	* configure.in (MKDEPDIR): Parallel build tweak.
+
+	* configure.in (ns_frag): New output file.
+
+	* configure.in (OLDXMENU): Set to "nothing" if !HAVE_X11 || USE_GTK.
+	(OLDXMENU_TARGET): Set to empty if USE_GTK.
+
+	* configure.in (cannot_dump): New output variable.
+
+2010-05-20  enami tsugutomo  <tsugutomo.enami@jp.sony.com>
+
+	* configure.in: On NetBSD, if terminfo is found, use it in
+	preference to termcap.  (Bug#6190)
+
+2010-05-20  Glenn Morris  <rgm@gnu.org>
+
+	* make-dist (src): Include *.mk.
+	* config.bat: Concatenate deps.mk onto the end of src/Makefile.
+	* configure.in (DEPFLAGS, MKDEPDIR): New output variables.
+	(deps_frag): New output file.
+	(AUTO_DEPEND): Remove this definition.
+
+	* configure.in (--with-gtk, --with-gcc): Remove option stubs.
+
+2010-05-19  Glenn Morris  <rgm@gnu.org>
+
+	* configure.in (LINKER, YMF_PASS_LDFLAGS): New output variables.
+	(ORDINARY_LINK): New AC_DEFINE.
+	(LIB_GCC): No need to set if ORDINARY_LINK.
+
 2010-05-18  Glenn Morris  <rgm@gnu.org>
 
 	* configure.in (POST_ALLOC_OBJ) [cygwin]: Omit vm-limit.o.
--- a/admin/notes/bugtracker	Tue May 25 09:32:24 2010 +0900
+++ b/admin/notes/bugtracker	Tue May 25 09:35:50 2010 +0900
@@ -553,9 +553,13 @@
 If a non-spam message accidentally gets discarded, just do:
 
 cat /var/lib/mailman/spam/not-really-spam.msg | /usr/lib/debbugs/receive
+chown Debian-debbugs:Debian-debbugs /var/lib/debbugs/spool/incoming/*
 ... check it works ...
 mv /var/lib/mailman/spam/not-really-spam.msg /var/lib/mailman/not-spam/
 
+Also check that the sender was not added to the auto-discard/reject list
+in the debbugs-submit Mailman interface.
+
 ** Administrivia
 
 The debbugs-submit list should have the administrivia option off,
--- a/config.bat	Tue May 25 09:32:24 2010 +0900
+++ b/config.bat	Tue May 25 09:35:50 2010 +0900
@@ -190,10 +190,11 @@
 if exist dir.h ren dir.h vmsdir.h
 
 rem   Create "makefile" from "makefile.in".
-rm -f Makefile junk.c
+rm -f Makefile junk.c junk2.c
 sed -e "1,/== start of cpp stuff ==/s@^##*[ 	].*$@@" <Makefile.in >junk.c
-gcc -E -traditional junk.c | sed -f ../msdos/sed1v2.inp >Makefile
-rm -f junk.c
+copy junk.c + deps.mk junk2.c
+gcc -E -traditional junk2.c | sed -f ../msdos/sed1v2.inp >Makefile
+rm -f junk.c junk2.c
 
 if "%X11%" == "" goto src5
 mv Makefile makefile.tmp
--- a/configure	Tue May 25 09:32:24 2010 +0900
+++ b/configure	Tue May 25 09:35:50 2010 +0900
@@ -701,6 +701,7 @@
 INSTALL_INFO
 GZIP_PROG
 MAKEINFO
+cannot_dump
 LD_SWITCH_SYSTEM
 C_SWITCH_MACHINE
 C_SWITCH_SYSTEM
@@ -714,6 +715,8 @@
 ALSA_LIBS
 CFLAGS_SOUND
 SET_MAKE
+MKDEPDIR
+DEPFLAGS
 XMKMF
 LD_SWITCH_X_SITE_AUX
 LD_SWITCH_X_SITE_AUX_RPATH
@@ -818,12 +821,15 @@
 POST_ALLOC_OBJ
 LD_SWITCH_SYSTEM_TEMACS
 LD_SWITCH_SYSTEM_EXTRA
+YMF_PASS_LDFLAGS
+LINKER
 LIB_GCC
 MOUSE_SUPPORT
 TOOLTIP_SUPPORT
 WINDOW_SUPPORT
 LTLIBOBJS'
-ac_subst_files=''
+ac_subst_files='deps_frag
+ns_frag'
 ac_user_opts='
 enable_option_checking
 with_pop
@@ -854,8 +860,6 @@
 with_gconf
 with_selinux
 with_makeinfo
-with_gtk
-with_gcc
 with_pkg_config_prog
 with_crt_dir
 with_gnustep_conf
@@ -1569,7 +1573,6 @@
   --without-gconf         don't compile with GConf support
   --without-selinux       don't compile with SELinux support
   --without-makeinfo      don't require makeinfo for building manuals
-
   --with-pkg-config-prog=PATH
                           path to pkg-config for finding GTK and librsvg
   --with-crt-dir=DIR      directory containing crtn.o etc. The default is
@@ -2382,28 +2385,6 @@
 
 
 
-# Check whether --with-gtk was given.
-if test "${with_gtk+set}" = set; then
-  withval=$with_gtk; { { $as_echo "$as_me:$LINENO: error: --with-gtk has been removed.  Use --with-x-toolkit to
-specify a toolkit." >&5
-$as_echo "$as_me: error: --with-gtk has been removed.  Use --with-x-toolkit to
-specify a toolkit." >&2;}
-   { (exit 1); exit 1; }; }
-fi
-
-
-
-# Check whether --with-gcc was given.
-if test "${with_gcc+set}" = set; then
-  withval=$with_gcc; { { $as_echo "$as_me:$LINENO: error: --with-gcc has been removed.  Set the \`CC' environment
-variable to specify a compiler." >&5
-$as_echo "$as_me: error: --with-gcc has been removed.  Set the \`CC' environment
-variable to specify a compiler." >&2;}
-   { (exit 1); exit 1; }; }
-fi
-
-
-
 # Check whether --with-pkg-config-prog was given.
 if test "${with_pkg_config_prog+set}" = set; then
   withval=$with_pkg_config_prog;
@@ -5851,6 +5832,12 @@
 
 configure___ unexec=UNEXEC
 
+#ifdef CANNOT_DUMP
+configure___ cannot_dump=yes
+#else
+configure___ cannot_dump=no
+#endif
+
 #ifdef SYSTEM_MALLOC
 configure___ system_malloc=yes
 #else
@@ -5912,6 +5899,9 @@
 rm ${tempcname}
 
 
+
+
+
 LD_SWITCH_SYSTEM=
 case "$opsys" in
   freebsd)
@@ -9501,6 +9491,9 @@
 fi
 
 
+DEPFLAGS=
+MKDEPDIR=":"
+deps_frag=deps.mk
 if test "$GCC" = yes && test "$ac_enable_autodepend" = yes; then
    { $as_echo "$as_me:$LINENO: checking whether we are using GNU Make" >&5
 $as_echo_n "checking whether we are using GNU Make... " >&6; }
@@ -9567,13 +9560,19 @@
 $as_echo "$ac_enable_autodepend" >&6; }
    fi
    if test $ac_enable_autodepend = yes; then
-
-cat >>confdefs.h <<\_ACEOF
-#define AUTO_DEPEND 1
-_ACEOF
-
+      DEPFLAGS='-MMD -MF ${DEPDIR}/$*.d'
+      ## In parallel builds, another make might create depdir between
+      ## the first test and mkdir, so stick another test on the end.
+      ## Or use mkinstalldirs?  mkdir -p is not portable.
+      MKDEPDIR='test -d ${DEPDIR} || mkdir ${DEPDIR} || test -d ${DEPDIR}'
+      deps_frag=autodeps.mk
    fi
 fi
+deps_frag=$srcdir/src/$deps_frag
+
+
+
+
 
 { $as_echo "$as_me:$LINENO: checking for long file names" >&5
 $as_echo_n "checking for long file names... " >&6; }
@@ -9960,6 +9959,7 @@
      GNUSTEP_SYSTEM_HEADERS="$(. $GNUSTEP_CONFIG_FILE; echo $GNUSTEP_SYSTEM_HEADERS)"
      GNUSTEP_SYSTEM_LIBRARIES="$(. $GNUSTEP_CONFIG_FILE; echo $GNUSTEP_SYSTEM_LIBRARIES)"
      ## Pull in stuff from GNUstep-make.
+     ## FIXME? Cleaner to use AC_SUBST_FILE for this?
      NS_IMPL_GNUSTEP_INC="FOUNDATION_LIB=gnu
 GUI_LIB=gnu
 include $GNUSTEP_MAKEFILES/Additional/base.make
@@ -10164,6 +10164,7 @@
 
 
 
+ns_frag=/dev/null
 NS_OBJ=
 NS_SUPPORT=
 if test "${HAVE_NS}" = yes; then
@@ -10175,6 +10176,7 @@
   if test "${EN_NS_SELF_CONTAINED}" = yes; then
      prefix=${ns_appresdir}
   fi
+  ns_frag=$srcdir/src/ns.mk
   NS_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o fontset.o fringe.o image.o"
   NS_SUPPORT="\${lispsource}emacs-lisp/easymenu.elc \${lispsource}term/ns-win.elc"
 fi
@@ -10184,6 +10186,7 @@
 
 
 
+
 case "${window_system}" in
   x11 )
     HAVE_X_WINDOWS=yes
@@ -21622,7 +21625,7 @@
 
 ## Use terminfo instead of termcap?
 ## Note only system files NOT using terminfo are:
-## freebsd < 40000, ms-w32, msdos, netbsd, and
+## freebsd < 40000, ms-w32, msdos, netbsd < 599002500, and
 ## darwin|gnu without ncurses.
 TERMINFO=no
 LIBS_TERMCAP=
@@ -21715,13 +21718,22 @@
     fi
     ;;
 
+  netbsd)
+    if test $ac_cv_search_tputs = -lterminfo; then
+      TERMINFO=yes
+      LIBS_TERMCAP="-lterminfo"
+    else
+      LIBS_TERMCAP="-ltermcap"
+    fi
+    ;;
+
 esac
 
 case "$opsys" in
   ## hpux: Make sure we get select from libc rather than from libcurses
   ##  because libcurses on HPUX 10.10 has a broken version of select.
   ##  We used to use -lc -lcurses, but this may be cleaner.
-  hpux*|netbsd) LIBS_TERMCAP="-ltermcap" ;;
+  hpux*) LIBS_TERMCAP="-ltermcap" ;;
 
   openbsd) LIBS_TERMCAP="-lncurses" ;;
 
@@ -26491,7 +26503,6 @@
 fi
 
 
-
 ## The X Menu stuff is present in the X10 distribution, but missing
 ## from X11.  If we have X10, just use the installed library;
 ## otherwise, use our own copy.
@@ -26511,7 +26522,9 @@
   LIBX_OTHER="\$(LIBXT) \$(LIBX_EXTRA)"
   OLDXMENU_DEPS="\${OLDXMENU} ../src/\${OLDXMENU}"
 else
-  OLDXMENU=
+  ## For a syntactically valid Makefile; not actually used for anything.
+  ## See comments in src/Makefile.in.
+  OLDXMENU=nothing
   ## FIXME This case (!HAVE_X11 && HAVE_X_WINDOWS) is no longer possible(?).
   if test "${HAVE_X_WINDOWS}" = "yes"; then
     LIBXMENU="-lXMenu"
@@ -26523,7 +26536,8 @@
 fi
 
 if test "$HAVE_GTK" = "yes" || test "$HAVE_MENUS" != "yes"; then
-  OLDXMENU=
+  OLDXMENU_TARGET=
+  OLDXMENU=nothing
   LIBXMENU=
   OLDXMENU_DEPS=
 fi
@@ -26533,6 +26547,7 @@
 
 
 
+
 if test "${HAVE_MENUS}" = "yes" ; then
 
 cat >>confdefs.h <<\_ACEOF
@@ -26616,8 +26631,79 @@
 
 
 
+LINKER=
+ORDINARY_LINK=
+case "$opsys" in
+  ## gnu: GNU needs its own crt0.
+  aix4-2|darwin|gnu|usg5-4|irix6-5|sol2*|unixware) ORDINARY_LINK=yes ;;
+
+  cygwin) LINKER="\$(CC)" ;;
+
+  ## On post 1.3 releases of NetBSD, gcc -nostdlib also clears the
+  ## library search parth, i.e. it won't search /usr/lib for libc and
+  ## friends.  Using -nostartfiles instead avoids this problem, and
+  ## will also work on earlier NetBSD releases.
+  netbsd|openbsd) LINKER="\$(CC) -nostartfiles" ;;
+
+  ## macpcc: NAKAJI Hiroyuki <nakaji@tutrp.tut.ac.jp> says
+  ##   MkLinux/LinuxPPC needs this.
+  ## ibms390x only supports opsys = gnu-linux so it can be added here.
+  gnu-*)
+    case "$machine" in
+      macppc|ibms390x) LINKER="\$(CC) -nostdlib" ;;
+    esac
+    ;;
+esac
+
+## A macro which other sections of Makefile can redefine to munge the
+## flags before they are passed to LD.  This is helpful if you have
+## redefined LD to something odd, like "gcc".
+## (The YMF prefix is a holdover from the old name "ymakefile".)
+YMF_PASS_LDFLAGS=flags
+if test "x$ORDINARY_LINK" = "xyes"; then
+
+  LINKER="\$(CC)"
+
+cat >>confdefs.h <<\_ACEOF
+#define ORDINARY_LINK 1
+_ACEOF
+
+
+## The system files defining neither ORDINARY_LINK nor LINKER are:
+## (bsd-common), freebsd, gnu-* not on macppc|ibms390x, hpux*.
+elif test "x$GCC" = "xyes" && test "x$LINKER" = "x"; then
+
+  ## Versions of GCC >= 2.0 put their library, libgcc.a, in obscure
+  ## places that are difficult to figure out at make time.  Fortunately,
+  ## these same versions allow you to pass arbitrary flags on to the
+  ## linker, so there is no reason not to use it as a linker.
+  ##
+  ## Well, it is not quite perfect.  The "-nostdlib" keeps GCC from
+  ## searching for libraries in its internal directories, so we have to
+  ## ask GCC explicitly where to find libgcc.a (LIB_GCC below).
+  LINKER="\$(CC) -nostdlib"
+  ## GCC passes any argument prefixed with -Xlinker directly to the linker.
+  ## See prefix-args.c for an explanation of why we do not do this with the
+  ## shell''s ``for'' construct.  Note that sane people do not have '.' in
+  ## their paths, so we must use ./prefix-args.
+  ## TODO either make prefix-args check ORDINARY_LINK internally,
+  ## or remove it altogether (bug#6184), removing the need for this macro.
+  YMF_PASS_LDFLAGS='`./prefix-args -Xlinker flags`'
+fi
+
+
+test "x$LINKER" = "x" && LINKER=ld
+## FIXME? What setting of YMF_PASS_LDFLAGS should this have?
+test "$NS_IMPL_GNUSTEP" = "yes" && LINKER="\$(CC) -rdynamic"
+
+
+
+
+## FIXME? The logic here is not precisely the same as that above
+## setting YMF_PASS_LDFLAGS.  There is no check here for a pre-defined
+## LINKER.  Should we only be setting LIB_GCC if LD ~ -nostdlib?
 LIB_GCC=
-if test "x$GCC" = "xyes"; then
+if test "x$GCC" = "xyes" && test "x$ORDINARY_LINK" != "xyes"; then
 
   case "$opsys" in
     ## cygwin: don't link against static libgcc.
@@ -27458,7 +27544,24 @@
 # This happens for instance with `./config.status config.h'.
 if test -n "$CONFIG_FILES"; then
 
-
+if $AWK 'BEGIN { getline <"/dev/null" }' </dev/null 2>/dev/null; then
+  ac_cs_awk_getline=:
+  ac_cs_awk_pipe_init=
+  ac_cs_awk_read_file='
+      while ((getline aline < (F[key])) > 0)
+	print(aline)
+      close(F[key])'
+  ac_cs_awk_pipe_fini=
+else
+  ac_cs_awk_getline=false
+  ac_cs_awk_pipe_init="print \"cat <<'|#_!!_#|' &&\""
+  ac_cs_awk_read_file='
+      print "|#_!!_#|"
+      print "cat " F[key] " &&"
+      '$ac_cs_awk_pipe_init
+  # The final `:' finishes the AND list.
+  ac_cs_awk_pipe_fini='END { print "|#_!!_#|"; print ":" }'
+fi
 ac_cr='
'
 ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
 if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
@@ -27470,6 +27573,19 @@
 echo 'BEGIN {' >"$tmp/subs1.awk" &&
 _ACEOF
 
+# Create commands to substitute file output variables.
+{
+  echo "cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1" &&
+  echo 'cat >>"\$tmp/subs1.awk" <<\\_ACAWK &&' &&
+  echo "$ac_subst_files" | sed 's/.*/F["&"]="$&"/' &&
+  echo "_ACAWK" &&
+  echo "_ACEOF"
+} >conf$$files.sh &&
+. ./conf$$files.sh ||
+  { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
+$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
+   { (exit 1); exit 1; }; }
+rm -f conf$$files.sh
 
 {
   echo "cat >conf$$subs.awk <<_ACEOF" &&
@@ -27551,7 +27667,7 @@
 cat >>"\$tmp/subs1.awk" <<_ACAWK &&
   for (key in S) S_is_set[key] = 1
   FS = ""
-
+  \$ac_cs_awk_pipe_init
 }
 {
   line = $ 0
@@ -27569,10 +27685,16 @@
     } else
       len += 1 + keylen
   }
-
+  if (nfields == 3 && !substed) {
+    key = field[2]
+    if (F[key] != "" && line ~ /^[	 ]*@.*@[	 ]*$/) {
+      \$ac_cs_awk_read_file
+      next
+    }
+  }
   print line
 }
-
+\$ac_cs_awk_pipe_fini
 _ACAWK
 _ACEOF
 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
@@ -27959,7 +28081,12 @@
 s&@INSTALL@&$ac_INSTALL&;t t
 $ac_datarootdir_hack
 "
-eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \
+eval sed \"\$ac_sed_extra\" "$ac_file_inputs" |
+if $ac_cs_awk_getline; then
+  $AWK -f "$tmp/subs.awk"
+else
+  $AWK -f "$tmp/subs.awk" | $SHELL
+fi >$tmp/out \
   || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
 $as_echo "$as_me: error: could not create $ac_file" >&2;}
    { (exit 1); exit 1; }; }
--- a/configure.in	Tue May 25 09:32:24 2010 +0900
+++ b/configure.in	Tue May 25 09:35:50 2010 +0900
@@ -2,9 +2,11 @@
 dnl To rebuild the `configure' script from this, execute the command
 dnl 	autoconf
 dnl in the directory containing this script.
+dnl If you changed any AC_DEFINES, also run autoheader.
 dnl
-dnl  Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2003,
-dnl    2004, 2005, 2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
+dnl  Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2003, 2004,
+dnl    2005, 2006, 2007, 2008, 2009, 2010
+dnl    Free Software Foundation, Inc.
 dnl
 dnl  This file is part of GNU Emacs.
 dnl
@@ -168,15 +170,6 @@
 dnl http://lists.gnu.org/archive/html/emacs-devel/2008-04/msg01844.html
 OPTION_DEFAULT_ON([makeinfo],[don't require makeinfo for building manuals])
 
-dnl Can remove these in Emacs 24.
-AC_ARG_WITH([gtk],,
-  [AC_MSG_ERROR([--with-gtk has been removed.  Use --with-x-toolkit to
-specify a toolkit.])],,)
-
-AC_ARG_WITH([gcc],,
-  [AC_MSG_ERROR([--with-gcc has been removed.  Set the `CC' environment
-variable to specify a compiler.])],,)
-
 AC_ARG_WITH([pkg-config-prog],dnl
 [AS_HELP_STRING([--with-pkg-config-prog=PATH],
                   [path to pkg-config for finding GTK and librsvg])])
@@ -864,6 +857,12 @@
 
 configure___ unexec=UNEXEC
 
+#ifdef CANNOT_DUMP
+configure___ cannot_dump=yes
+#else
+configure___ cannot_dump=no
+#endif
+
 #ifdef SYSTEM_MALLOC
 configure___ system_malloc=yes
 #else
@@ -925,6 +924,9 @@
 rm ${tempcname}
 
 
+AC_SUBST(cannot_dump)
+
+
 LD_SWITCH_SYSTEM=
 case "$opsys" in
   freebsd)
@@ -1348,6 +1350,9 @@
 dnl check for Make feature
 AC_PROG_MAKE_SET
 
+DEPFLAGS=
+MKDEPDIR=":"
+deps_frag=deps.mk
 dnl check for GNU Make if we have GCC and autodepend is on.
 if test "$GCC" = yes && test "$ac_enable_autodepend" = yes; then
    AC_MSG_CHECKING([whether we are using GNU Make])
@@ -1370,9 +1375,19 @@
       AC_MSG_RESULT([$ac_enable_autodepend])
    fi
    if test $ac_enable_autodepend = yes; then
-      AC_DEFINE(AUTO_DEPEND, 1, [Generate dependencies with gcc.])
+      DEPFLAGS='-MMD -MF ${DEPDIR}/$*.d'
+      ## In parallel builds, another make might create depdir between
+      ## the first test and mkdir, so stick another test on the end.
+      ## Or use mkinstalldirs?  mkdir -p is not portable.
+      MKDEPDIR='test -d ${DEPDIR} || mkdir ${DEPDIR} || test -d ${DEPDIR}'
+      deps_frag=autodeps.mk
    fi
 fi
+deps_frag=$srcdir/src/$deps_frag
+AC_SUBST(MKDEPDIR)
+AC_SUBST(DEPFLAGS)
+AC_SUBST_FILE(deps_frag)
+
 
 dnl checks for operating system services
 AC_SYS_LONG_FILE_NAMES
@@ -1480,6 +1495,7 @@
      GNUSTEP_SYSTEM_HEADERS="$(. $GNUSTEP_CONFIG_FILE; echo $GNUSTEP_SYSTEM_HEADERS)"
      GNUSTEP_SYSTEM_LIBRARIES="$(. $GNUSTEP_CONFIG_FILE; echo $GNUSTEP_SYSTEM_LIBRARIES)"
      ## Pull in stuff from GNUstep-make.
+     ## FIXME? Cleaner to use AC_SUBST_FILE for this?
      NS_IMPL_GNUSTEP_INC="FOUNDATION_LIB=gnu
 GUI_LIB=gnu
 include $GNUSTEP_MAKEFILES/Additional/base.make
@@ -1512,6 +1528,7 @@
 AC_SUBST(NS_IMPL_GNUSTEP_TEMACS_LDFLAGS)
 AC_SUBST(TEMACS_LDFLAGS2)
 
+ns_frag=/dev/null
 NS_OBJ=
 NS_SUPPORT=
 if test "${HAVE_NS}" = yes; then
@@ -1523,6 +1540,7 @@
   if test "${EN_NS_SELF_CONTAINED}" = yes; then
      prefix=${ns_appresdir}
   fi
+  ns_frag=$srcdir/src/ns.mk
   NS_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o fontset.o fringe.o image.o"
   NS_SUPPORT="\${lispsource}emacs-lisp/easymenu.elc \${lispsource}term/ns-win.elc"
 fi
@@ -1531,6 +1549,7 @@
 AC_SUBST(NS_OBJ)
 AC_SUBST(NS_SUPPORT)
 AC_SUBST(LIB_STANDARD)
+AC_SUBST_FILE(ns_frag)
 
 case "${window_system}" in
   x11 )
@@ -2640,7 +2659,7 @@
 
 ## Use terminfo instead of termcap?
 ## Note only system files NOT using terminfo are:
-## freebsd < 40000, ms-w32, msdos, netbsd, and
+## freebsd < 40000, ms-w32, msdos, netbsd < 599002500, and
 ## darwin|gnu without ncurses.
 TERMINFO=no
 LIBS_TERMCAP=
@@ -2682,13 +2701,22 @@
     fi
     ;;
 
+  netbsd)
+    if test $ac_cv_search_tputs = -lterminfo; then
+      TERMINFO=yes
+      LIBS_TERMCAP="-lterminfo"
+    else
+      LIBS_TERMCAP="-ltermcap"
+    fi
+    ;;
+
 esac
 
 case "$opsys" in
   ## hpux: Make sure we get select from libc rather than from libcurses
   ##  because libcurses on HPUX 10.10 has a broken version of select.
   ##  We used to use -lc -lcurses, but this may be cleaner.
-  hpux*|netbsd) LIBS_TERMCAP="-ltermcap" ;;
+  hpux*) LIBS_TERMCAP="-ltermcap" ;;
 
   openbsd) LIBS_TERMCAP="-lncurses" ;;
 
@@ -3159,7 +3187,6 @@
   OLDXMENU_TARGET="really-lwlib"
 fi
 AC_SUBST(LIBXT_OTHER)
-AC_SUBST(OLDXMENU_TARGET)
 
 ## The X Menu stuff is present in the X10 distribution, but missing
 ## from X11.  If we have X10, just use the installed library;
@@ -3178,7 +3205,9 @@
   LIBX_OTHER="\$(LIBXT) \$(LIBX_EXTRA)"
   OLDXMENU_DEPS="\${OLDXMENU} ../src/\${OLDXMENU}"
 else
-  OLDXMENU=
+  ## For a syntactically valid Makefile; not actually used for anything.
+  ## See comments in src/Makefile.in.
+  OLDXMENU=nothing
   ## FIXME This case (!HAVE_X11 && HAVE_X_WINDOWS) is no longer possible(?).
   if test "${HAVE_X_WINDOWS}" = "yes"; then
     LIBXMENU="-lXMenu"
@@ -3190,11 +3219,13 @@
 fi
 
 if test "$HAVE_GTK" = "yes" || test "$HAVE_MENUS" != "yes"; then
-  OLDXMENU=
+  OLDXMENU_TARGET=
+  OLDXMENU=nothing  
   LIBXMENU=
   OLDXMENU_DEPS=
 fi
 
+AC_SUBST(OLDXMENU_TARGET)
 AC_SUBST(OLDXMENU)
 AC_SUBST(LIBXMENU)
 AC_SUBST(LIBX_OTHER)
@@ -3277,8 +3308,75 @@
 AC_SUBST(LD_SWITCH_SYSTEM_EXTRA)
 
 
+LINKER=
+ORDINARY_LINK=
+case "$opsys" in
+  ## gnu: GNU needs its own crt0.
+  aix4-2|darwin|gnu|usg5-4|irix6-5|sol2*|unixware) ORDINARY_LINK=yes ;;
+
+  cygwin) LINKER="\$(CC)" ;;
+
+  ## On post 1.3 releases of NetBSD, gcc -nostdlib also clears the
+  ## library search parth, i.e. it won't search /usr/lib for libc and
+  ## friends.  Using -nostartfiles instead avoids this problem, and
+  ## will also work on earlier NetBSD releases.
+  netbsd|openbsd) LINKER="\$(CC) -nostartfiles" ;;
+
+  ## macpcc: NAKAJI Hiroyuki <nakaji@tutrp.tut.ac.jp> says
+  ##   MkLinux/LinuxPPC needs this.
+  ## ibms390x only supports opsys = gnu-linux so it can be added here.
+  gnu-*)
+    case "$machine" in
+      macppc|ibms390x) LINKER="\$(CC) -nostdlib" ;;
+    esac
+    ;;
+esac
+
+## A macro which other sections of Makefile can redefine to munge the
+## flags before they are passed to LD.  This is helpful if you have
+## redefined LD to something odd, like "gcc".
+## (The YMF prefix is a holdover from the old name "ymakefile".) 
+YMF_PASS_LDFLAGS=flags
+if test "x$ORDINARY_LINK" = "xyes"; then
+
+  LINKER="\$(CC)"
+  AC_DEFINE(ORDINARY_LINK, 1, [Define if the C compiler is the linker.])
+
+## The system files defining neither ORDINARY_LINK nor LINKER are:
+## (bsd-common), freebsd, gnu-* not on macppc|ibms390x, hpux*.
+elif test "x$GCC" = "xyes" && test "x$LINKER" = "x"; then
+
+  ## Versions of GCC >= 2.0 put their library, libgcc.a, in obscure
+  ## places that are difficult to figure out at make time.  Fortunately,
+  ## these same versions allow you to pass arbitrary flags on to the
+  ## linker, so there is no reason not to use it as a linker.
+  ##
+  ## Well, it is not quite perfect.  The "-nostdlib" keeps GCC from
+  ## searching for libraries in its internal directories, so we have to
+  ## ask GCC explicitly where to find libgcc.a (LIB_GCC below).
+  LINKER="\$(CC) -nostdlib"
+  ## GCC passes any argument prefixed with -Xlinker directly to the linker.
+  ## See prefix-args.c for an explanation of why we do not do this with the
+  ## shell''s ``for'' construct.  Note that sane people do not have '.' in
+  ## their paths, so we must use ./prefix-args.
+  ## TODO either make prefix-args check ORDINARY_LINK internally,
+  ## or remove it altogether (bug#6184), removing the need for this macro.
+  YMF_PASS_LDFLAGS='`./prefix-args -Xlinker flags`'
+fi
+AC_SUBST(YMF_PASS_LDFLAGS)
+
+test "x$LINKER" = "x" && LINKER=ld
+## FIXME? What setting of YMF_PASS_LDFLAGS should this have?
+test "$NS_IMPL_GNUSTEP" = "yes" && LINKER="\$(CC) -rdynamic"
+
+AC_SUBST(LINKER)
+
+
+## FIXME? The logic here is not precisely the same as that above
+## setting YMF_PASS_LDFLAGS.  There is no check here for a pre-defined
+## LINKER.  Should we only be setting LIB_GCC if LD ~ -nostdlib?
 LIB_GCC=
-if test "x$GCC" = "xyes"; then
+if test "x$GCC" = "xyes" && test "x$ORDINARY_LINK" != "xyes"; then
 
   case "$opsys" in
     ## cygwin: don't link against static libgcc.
--- a/doc/lispref/ChangeLog	Tue May 25 09:32:24 2010 +0900
+++ b/doc/lispref/ChangeLog	Tue May 25 09:35:50 2010 +0900
@@ -1,3 +1,8 @@
+2010-05-22  Chong Yidong  <cyd@stupidchicken.com>
+
+	* display.texi (Image Cache): Update documentation about image
+	caching.
+
 2010-05-08  Štěpán Němec  <stepnem@gmail.com>  (tiny change)
 
 	* windows.texi (Textual Scrolling):
--- a/doc/lispref/display.texi	Tue May 25 09:32:24 2010 +0900
+++ b/doc/lispref/display.texi	Tue May 25 09:35:50 2010 +0900
@@ -4730,29 +4730,35 @@
 efficiently.  When Emacs displays an image, it searches the image
 cache for an existing image specification @code{equal} to the desired
 specification.  If a match is found, the image is displayed from the
-cache; otherwise, Emacs loads the image normally.
-
-  Occasionally, you may need to tell Emacs to refresh the images
-associated with a given image specification.  For example, suppose you
-display an image using a specification that contains a @code{:file}
-property.  The image is automatically cached, and subsequent displays
-of that image, with the same image specification, will use the image
-cache.  If the image file changes in the meantime, Emacs would be
-displaying the old version of the image.  In such a situation, you can
-``refresh'' the image by calling @code{image-refresh}.
-
-  In Emacs' current implementation, each graphical terminal possesses
-an image cache, which is shared by all the frames on that terminal
+cache.  Otherwise, Emacs loads the image normally.
+
+@defun image-flush spec &optional frame
+This function removes the image with specification @var{spec} from the
+image cache of frame @var{frame}.  Image specifications are compared
+using @code{equal}.  If @var{frame} is @code{nil}, it defaults to the
+selected frame.  If @var{frame} is @code{t}, the image is flushed on
+all existing frames.
+
+In Emacs' current implementation, each graphical terminal possesses an
+image cache, which is shared by all the frames on that terminal
 (@pxref{Multiple Terminals}).  Thus, refreshing an image in one frame
 also refreshes it in all other frames on the same terminal.
-
-@defun image-refresh spec &optional frame
-This function refreshes any images with image specifications
-@code{equal} to @var{spec} on frame @var{frame}.  If @var{frame} is
-@code{nil}, it defaults to the selected frame.  If @var{frame} is
-@code{t}, the refresh is applied to all existing frames.
 @end defun
 
+  One use for @code{image-flush} is to tell Emacs about a change in an
+image file.  If an image specification contains a @code{:file}
+property, the image is cached based on the file's contents when the
+image is first displayed.  Even if the file subsequently changes,
+Emacs continues displaying the old version of the image.  Calling
+@code{image-flush} flushes the image from the cache, forcing Emacs to
+re-read the file the next time it needs to display that image.
+
+  Another use for @code{image-flush} is for memory conservation.  If
+your Lisp program creates a large number of temporary images over a
+period much shorter than @code{image-cache-eviction-delay} (see
+below), you can opt to flush unused images yourself, instead of
+waiting for Emacs to do it automatically.
+
 @defun clear-image-cache &optional filter
 This function clears an image cache, removing all the images stored in
 it.  If @var{filter} is omitted or @code{nil}, it clears the cache for
@@ -4768,9 +4774,12 @@
 associated memory.
 
 @defvar image-cache-eviction-delay
-This variable specifies the number of seconds an image can remain in the
-cache without being displayed.  When an image is not displayed for this
-length of time, Emacs removes it from the image cache.
+This variable specifies the number of seconds an image can remain in
+the cache without being displayed.  When an image is not displayed for
+this length of time, Emacs removes it from the image cache.
+
+Under some circumstances, if the number of images in the cache grows
+too large, the actual eviction delay may be shorter than this.
 
 If the value is @code{nil}, Emacs does not remove images from the cache
 except when you explicitly clear it.  This mode can be useful for
--- a/etc/NEWS	Tue May 25 09:32:24 2010 +0900
+++ b/etc/NEWS	Tue May 25 09:35:50 2010 +0900
@@ -147,6 +147,11 @@
 *** The color widget now has a "Choose" button, which allows you to
 choose a color via list-colors-display.
 
+** Dired-x
+
+*** dired-jump and dired-jump-other-window called with a prefix argument
+read a file name from the minibuffer instead of using buffer-file-name.
+
 ** VC and related modes
 
 *** New VC commands: vc-log-incoming, vc-log-outgoing, vc-find-conflicted-file.
@@ -250,6 +255,10 @@
 
 *** `image-extension-data' is renamed to `image-metadata'.
 
+** Isearch
+
+*** New hook `isearch-update-post-hook' that runs in `isearch-update'.
+
 ** Progress reporters can now "spin".
 The MIN-VALUE and MAX-VALUE arguments of `make-progress-reporter' can
 now be nil, or omitted.  This makes a "non-numeric" reporter.  Each
--- a/etc/TODO	Tue May 25 09:32:24 2010 +0900
+++ b/etc/TODO	Tue May 25 09:35:50 2010 +0900
@@ -40,9 +40,9 @@
   fix_submap_inheritance hack and to more cleanly express the
   relationship between minibuffer-local-*-map): I've had this locally
   for a long time, but the details of the semantics is somewhat ... delicate.
-*** prog-mode (a parent-mode, like text-mode).  Could/should provide
-  a better fill-paragraph default that uses syntax-tables to recognize
-  string/comment boundaries.
+*** Derive from prog-mode in more places, close bug#5532.
+*** prog-mode could/should provide a better fill-paragraph default
+  that uses syntax-tables to recognize string/comment boundaries.
 *** provide more completion-at-point-functions.  Make existing
   in-buffer completion use completion-at-point.
 *** "functional" function-key-map that would make it easy to add (and
@@ -181,7 +181,14 @@
 http://lists.gnu.org/archive/html/emacs-devel/2008-08/msg00456.html
 
 * Important features:
-
+** Extended text-properties (to make overlays "obsolete")
+*** Several text-property planes
+This would get us rid of font-lock-face property (and I'd be happy to
+get rid of char-property-alias-alist as well) since font-lock would
+simply use the `face' property in the `font-lock' plane.
+Each property would come with an Elisp merge-function.  The merge
+would be performed in add-text-properties.
+*** zero-width text-properties.
 ** Having tabs above a window to switch buffers in it.
 
 ** "Perspectives" are named persistent window configurations.  We have
--- a/lib-src/ChangeLog	Tue May 25 09:32:24 2010 +0900
+++ b/lib-src/ChangeLog	Tue May 25 09:35:50 2010 +0900
@@ -1,3 +1,11 @@
+2010-05-22  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* Makefile.in (STAMP_INST_SCRIPTS, STAMP_SCRIPS): New (Bug #6246).
+	(all): Depend onSTAMP_INST_SCRIPTS, STAMP_SCRIPS (Bug #6246).
+	(stamp-rcs2log, stamp-rcs-checkin, stamp-grep-changelog, stamp-vcdiff):
+	New rules (Bug #6246).
+	(clean): Remove stamp-* (Bug #6246).
+
 2010-05-12  Glenn Morris  <rgm@gnu.org>
 
 	* Makefile.in (INSTALLABLES): Remove @LIB_SRC_EXTRA_INSTALLABLES@.
--- a/lib-src/Makefile.in	Tue May 25 09:32:24 2010 +0900
+++ b/lib-src/Makefile.in	Tue May 25 09:35:50 2010 +0900
@@ -111,6 +111,7 @@
                b2m${EXEEXT} ebrowse${EXEEXT}
 
 INSTALLABLE_SCRIPTS = rcs-checkin grep-changelog
+STAMP_INST_SCRIPTS = stamp-rcs-checkin stamp-grep-changelog
 
 # Things that Emacs runs internally, or during the build process,
 #  which should not be installed in bindir.
@@ -123,6 +124,7 @@
 # Like UTILITIES, but they're not system-dependent, and should not be
 #  deleted by the distclean target.
 SCRIPTS= rcs2log vcdiff
+STAMP_SCRIPTS= stamp-rcs2log stamp-vcdiff
 
 EXECUTABLES= ${UTILITIES} ${INSTALLABLES} ${SCRIPTS} ${INSTALLABLE_SCRIPTS}
 
@@ -180,23 +182,27 @@
 .c.o:
 	${CC} -c ${CPP_CFLAGS} $<
 
-all: ${DONT_INSTALL} ${UTILITIES} ${INSTALLABLES} ${SCRIPTS} ${INSTALLABLE_SCRIPTS}
+all: ${DONT_INSTALL} ${UTILITIES} ${INSTALLABLES} ${SCRIPTS} ${INSTALLABLE_SCRIPTS}  ${STAMP_INST_SCRIPTS} ${STAMP_SCRIPTS}
 
 ## These targets copy the scripts into the build directory so that
 ## they can be run from there in an uninstalled Emacs.
 ## The "-" is prepended because some versions of cp barf when srcdir
 ## is the current directory, and thus the file will be copied into itself.
-rcs2log: $(srcdir)/rcs2log
+stamp-rcs2log: $(srcdir)/rcs2log
 	-cp -p $(srcdir)/rcs2log rcs2log
+	touch $@
 
-rcs-checkin: $(srcdir)/rcs-checkin
+stamp-rcs-checkin: $(srcdir)/rcs-checkin
 	-cp -p $(srcdir)/rcs-checkin rcs-checkin
+	touch $@
 
-grep-changelog: $(srcdir)/grep-changelog
+stamp-grep-changelog: $(srcdir)/grep-changelog
 	-cp -p $(srcdir)/grep-changelog grep-changelog
+	touch $@
 
-vcdiff: $(srcdir)/vcdiff
+stamp-vcdiff: $(srcdir)/vcdiff
 	-cp -p $(srcdir)/vcdiff vcdiff
+	touch $@
 
 ## Only used if we need blessmail, but no harm in always defining.
 ## This makes the actual blessmail executable.
@@ -273,7 +279,7 @@
 
 clean: mostlyclean
 	-rm -f ${INSTALLABLES} ${UTILITIES} ${DONT_INSTALL}
-	-rm -f fns*.el *.tab.c *.tab.h
+	-rm -f fns*.el *.tab.c *.tab.h stamp-*
 
 distclean: clean
 	-rm -f TAGS
--- a/lisp/ChangeLog	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/ChangeLog	Tue May 25 09:35:50 2010 +0900
@@ -1,8 +1,159 @@
+2010-05-22  Chong Yidong  <cyd@stupidchicken.com>
+
+	* image.el (image-refresh): Define as an alias for image-flush.
+
+	* image-mode.el (image-toggle-display-image): Caller changed.
+
+2010-05-21  Juri Linkov  <juri@jurta.org>
+
+	* progmodes/grep.el (grep-read-files): Fix multi-pattern aliases.
+	Remove "all" from grep-files-aliases.  Split grep-files-aliases by
+	whitespace, call wildcard-to-regexp on substrings and concat them
+	with "\\|".  (Bug#6114)
+
+2010-05-21  Alan Mackenzie  <acm@muc.de>
+
+	* progmodes/cc-engine.el (c-parse-state-get-strategy): Replace
+	parameter `here' with `here-' and `here-plus', which sandwich any
+	pertinent CPP construct.
+	(c-remove-stale-state-cache-backwards): Fix a bug which happens
+	when doing (c-parse-state) in a CPP construct: Exclude any "new"
+	CPP construct from taking part in the scanning.
+
+2010-05-21  Michael Albinus  <michael.albinus@gmx.de>
+
+	* net/tramp.el (tramp-do-copy-or-rename-file)
+	(tramp-handle-file-local-copy, tramp-maybe-open-connection): Tune
+	`with-progress-reporter' messages.
+	(tramp-handle-vc-registered):
+	* net/tramp-fish.el (tramp-fish-handle-file-local-copy)
+	(tramp-fish-handle-insert-file-contents)
+	(tramp-fish-maybe-open-connection):
+	* net/tramp-gvfs.el (tramp-gvfs-maybe-open-connection):
+	* net/tramp-imap.el (tramp-imap-do-copy-or-rename-file)
+	(tramp-imap-handle-insert-file-contents)
+	(tramp-imap-handle-file-local-copy): Use `with-progress-reporter'.
+
+2010-05-21  Juanma Barranquero  <lekktu@gmail.com>
+
+	* add-log.el (change-log-font-lock-keywords):
+	Highlight all authors in multi-author entries.
+
+	* smerge-mode.el (smerge-refine-ignore-whitespace)
+	(smerge-refine-weight-hack, smerge-refine, smerge-makeup-conflict):
+	Fix typos in docstrings.
+	(smerge-resolve, smerge-refine-subst): Reflow docstrings.
+
+2010-05-21  Glenn Morris  <rgm@gnu.org>
+
+	* progmodes/fortran.el (fortran-mode):
+	* progmodes/f90.el (f90-mode): Derive from prog-mode.
+
+	* loadup.el [CANNOT_DUMP]: Update for bootstrap-emacs no longer
+	having a relative path in src/Makefile.in.
+
+2010-05-20  Kevin Ryde  <user42@zip.com.au>
+
+	* help-mode.el (help-make-xrefs): For Info node links turn
+	newlines into spaces.  Link node names with newlines are matched
+	by help-xref-info-regexp and buttonized, this change ensures they
+	can be followed successfully with RET.  (Bug#6206)
+
+2010-05-20  Juri Linkov  <juri@jurta.org>
+
+	* locate.el (locate): Use pop-to-buffer instead of
+	switch-to-buffer-other-window.  (Bug#6204)
+
+2010-05-20  Juri Linkov  <juri@jurta.org>
+
+	* replace.el (replace-highlight): Fix lazy-highlighting
+	for `M-s w str M-% str RET'.
+
+2009-12-15  Masatake YAMATO  <yamato@redhat.com>
+
+	* isearch.el (isearch-yank-word-or-char): Pull next subword
+	when `subword-mode' is activated.  (Bug#6220)
+
+2010-05-20  Mark A. Hershberger  <mah@everybody.org>
+
+	* isearch.el (isearch-update-post-hook): New hook.
+	(isearch-update): Use the new hook.  (Bug#6225)
+
+2010-05-20  Juri Linkov  <juri@jurta.org>
+
+	* isearch.el (isearch-mode-map): Bind more keys to isearch-help-map:
+	[f1], [help], and (char-to-string help-char) instead of "\C-h".
+	(Bug#6222)
+
+2010-05-20  Juri Linkov  <juri@jurta.org>
+
+	* isearch.el (isearch-yank-string): Use isearch-process-search-string.
+	(Bug#6223)
+
+2010-05-20  Juri Linkov  <juri@jurta.org>
+
+	* dired-x.el (dired-jump, dired-jump-other-window): Add arg
+	FILE-NAME to read from the minibuffer when called interactively
+	with prefix argument instead of using buffer-file-name.
+	http://lists.gnu.org/archive/html/emacs-devel/2010-05/msg00534.html
+
+	* dired.el: Update autoloads.
+
+2010-05-20  Chong Yidong  <cyd@stupidchicken.com>
+
+	* nxml/nxml-mode.el (nxml-mode-map): Bind C-c / to
+	nxml-finish-element, for consistency with SGML mode.
+
+	* progmodes/octave-mod.el (octave-mode-map): Bind C-c / to
+	octave-close-block.
+
+2010-05-20  Juanma Barranquero  <lekktu@gmail.com>
+
+	* composite.el: Require cl when compiling.
+	(reference-point-alist, compose-gstring-for-graphic)
+	(compose-gstring-for-terminal): Fix typos in docstrings.
+
+2010-05-19  Juri Linkov  <juri@jurta.org>
+
+	* emacs-lisp/cl-macs.el (window-parameter): Add defsetf with
+	set-window-parameter.
+
+2010-05-19  Michael Albinus  <michael.albinus@gmx.de>
+
+	* net/tramp.el (tramp-methods): Add `tramp-async-args' attribute
+	where appropriate.
+	(tramp-maybe-open-connection): Use it.
+
+2010-05-19  Eli Zaretskii  <eliz@gnu.org>
+
+	* simple.el (move-end-of-line): Make sure we are at line beginning
+	before backing up to end of previous line.
+
+2010-05-19  Michael Albinus  <michael.albinus@gmx.de>
+
+	* password-cache.el (password-cache-remove): Fix docstring.
+
+	* net/secrets.el: Autoload the widget functions.
+	(secrets-search-items, secrets-create-item)
+	(secrets-get-attributes, secrets-expand-item): Attributes will be
+	stored on the password database without leading ":", as all other
+	clients do as well.
+	(secrets-mode): Fix docstring.
+	(secrets-show-secrets): Provide it as autoloaded command only when
+	D-Bus support is available.  Check existence of Secret Service API.
+
+2010-05-19  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* indent.el (indent-region): Deactivate region (bug#6200).
+
+2010-05-19  Glenn Morris  <rgm@gnu.org>
+
+	* vc-dir.el (vc-dir): Don't pop-up-windows.  (Bug#6204)
+
 2010-05-19  Kenichi Handa  <handa@m17n.org>
 
 	* composite.el: Register compose-gstring-for-graphic in
-	composition-function-table only for combining characters (Mn, Mc,
-	Me).
+	composition-function-table only for combining characters (Mn, Mc, Me).
 
 2010-05-18  Jay Belanger  <jay.p.belanger@gmail.com>
 
--- a/lisp/add-log.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/add-log.el	Tue May 25 09:35:50 2010 +0900
@@ -245,7 +245,7 @@
     ;; wrongly with a non-date line existing as a random note.  In
     ;; addition, using any kind of fixed setting like this doesn't
     ;; work if a user customizes add-log-time-format.
-    ("^[0-9-]+ +\\|^\\(Sun\\|Mon\\|Tue\\|Wed\\|Thu\\|Fri\\|Sat\\) [A-z][a-z][a-z] [0-9:+ ]+"
+    ("^[0-9-]+ +\\|^ \\{11,\\}\\|^\\(Sun\\|Mon\\|Tue\\|Wed\\|Thu\\|Fri\\|Sat\\) [A-z][a-z][a-z] [0-9:+ ]+"
      (0 'change-log-date-face)
      ;; Name and e-mail; some people put e-mail in parens, not angles.
      ("\\([^<(]+?\\)[ \t]*[(<]\\([A-Za-z0-9_.+-]+@[A-Za-z0-9_.-]+\\)[>)]" nil nil
--- a/lisp/comint.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/comint.el	Tue May 25 09:35:50 2010 +0900
@@ -309,7 +309,6 @@
   :type 'integer
   :group 'comint)
 
-;; FIXME: this should be defcustom
 (defcustom comint-input-ring-size 500
   "Size of the input history ring in `comint-mode'."
   :type 'integer
--- a/lisp/composite.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/composite.el	Tue May 25 09:35:50 2010 +0900
@@ -28,6 +28,8 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'cl))
+
 (defconst reference-point-alist
   '((tl . 0) (tc . 1) (tr . 2)
     (Bl . 3) (Bc . 4) (Br . 5)
@@ -77,7 +79,7 @@
     +----+-----+ <--- new descent
 
 A composition rule may have the form \(GLOBAL-REF-POINT
-NEW-REF-POINT XOFF YOFF), where XOFF and YOFF specifies how much
+NEW-REF-POINT XOFF YOFF), where XOFF and YOFF specify how much
 to shift NEW-REF-POINT from GLOBAL-REF-POINT.  In this case, XOFF
 and YOFF are integers in the range -100..100 representing the
 shifting percentage against the font size.")
@@ -537,7 +539,7 @@
 each combining character is composed as a spacing character by
 a padding space before and/or after the character.
 
-All non-spacing characters has this function in
+All non-spacing characters have this function in
 `composition-function-table' unless overwritten."
   (let* ((header (lgstring-header gstring))
 	 (nchars (lgstring-char-len gstring))
@@ -669,7 +671,7 @@
 Non-spacing characters are composed with the preceding base
 character.  If the preceding character is not a base character,
 each non-spacing character is composed as a spacing character by
-a prepending a space before it."
+prepending a space before it."
   (let* ((header (lgstring-header gstring))
 	 (nchars (lgstring-char-len gstring))
 	 (nglyphs (lgstring-glyph-len gstring))
--- a/lisp/dired-x.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/dired-x.el	Tue May 25 09:35:50 2010 +0900
@@ -506,16 +506,21 @@
 ;;; JUMP.
 
 ;;;###autoload
-(defun dired-jump (&optional other-window)
+(defun dired-jump (&optional other-window file-name)
   "Jump to dired buffer corresponding to current buffer.
 If in a file, dired the current directory and move to file's line.
 If in Dired already, pop up a level and goto old directory's line.
 In case the proper dired file line cannot be found, refresh the dired
-buffer and try again."
-  (interactive "P")
-  (let* ((file buffer-file-name)
+buffer and try again.
+When OTHER-WINDOW is non-nil, jump to dired buffer in other window.
+Interactively with prefix argument, read FILE-NAME and
+move to its line in dired."
+  (interactive
+   (list nil (and current-prefix-arg
+		  (read-file-name "Jump to dired file: "))))
+  (let* ((file (or file-name buffer-file-name))
          (dir (if file (file-name-directory file) default-directory)))
-    (if (eq major-mode 'dired-mode)
+    (if (and (eq major-mode 'dired-mode) (null file-name))
         (progn
           (setq dir (dired-current-directory))
           (dired-up-directory other-window)
@@ -539,10 +544,12 @@
 		    (dired-omit-mode)
 		    (dired-goto-file file))))))))
 
-(defun dired-jump-other-window ()
+(defun dired-jump-other-window (&optional file-name)
   "Like \\[dired-jump] (`dired-jump') but in other window."
-  (interactive)
-  (dired-jump t))
+  (interactive
+   (list (and current-prefix-arg
+	      (read-file-name "Jump to dired file: "))))
+  (dired-jump t file-name))
 
 ;;; OMITTING.
 
--- a/lisp/dired.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/dired.el	Tue May 25 09:35:50 2010 +0900
@@ -3974,7 +3974,7 @@
 ;;;***
 
 ;;;### (autoloads (dired-do-relsymlink dired-jump) "dired-x" "dired-x.el"
-;;;;;;  "2f8d3d5a31b969b181e23c40d6bb16a0")
+;;;;;;  "6c492aba3ca0d36a4cd7b02fb9c1cc10")
 ;;; Generated autoloads from dired-x.el
 
 (autoload 'dired-jump "dired-x" "\
@@ -3983,8 +3983,11 @@
 If in Dired already, pop up a level and goto old directory's line.
 In case the proper dired file line cannot be found, refresh the dired
 buffer and try again.
-
-\(fn &optional OTHER-WINDOW)" t nil)
+When OTHER-WINDOW is non-nil, jump to dired buffer in other window.
+Interactively with prefix argument, read FILE-NAME and
+move to its line in dired.
+
+\(fn &optional OTHER-WINDOW FILE-NAME)" t nil)
 
 (autoload 'dired-do-relsymlink "dired-x" "\
 Relative symlink all marked (or next ARG) files into a directory.
--- a/lisp/emacs-lisp/cl-loaddefs.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/emacs-lisp/cl-loaddefs.el	Tue May 25 09:35:50 2010 +0900
@@ -282,7 +282,7 @@
 ;;;;;;  flet progv psetq do-all-symbols do-symbols dotimes dolist
 ;;;;;;  do* do loop return-from return block etypecase typecase ecase
 ;;;;;;  case load-time-value eval-when destructuring-bind function*
-;;;;;;  defmacro* defun* gentemp gensym) "cl-macs" "cl-macs.el" "0faa39d8f21ae59f2cc1baa835e28a5f")
+;;;;;;  defmacro* defun* gentemp gensym) "cl-macs" "cl-macs.el" "fbeedbf769c72fee9b4e0671957c1077")
 ;;; Generated autoloads from cl-macs.el
 
 (autoload 'gensym "cl-macs" "\
--- a/lisp/emacs-lisp/cl-macs.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/emacs-lisp/cl-macs.el	Tue May 25 09:35:50 2010 +0900
@@ -1813,6 +1813,7 @@
 (defsetf window-height () (store)
   (list 'progn (list 'enlarge-window (list '- store '(window-height))) store))
 (defsetf window-hscroll set-window-hscroll)
+(defsetf window-parameter set-window-parameter)
 (defsetf window-point set-window-point)
 (defsetf window-start set-window-start)
 (defsetf window-width () (store)
--- a/lisp/gnus/ChangeLog	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/gnus/ChangeLog	Tue May 25 09:35:50 2010 +0900
@@ -1,3 +1,7 @@
+2010-05-20  Kevin Ryde  <user42@zip.com.au>
+
+	* gnus-start.el (gnus-level-unsubscribed): Doc fix.  (Bug#6206)
+
 2010-05-14  Katsumi Yamaoka  <yamaoka@jpl.org>
 
 	* gnus-sum.el (gnus-summary-save-article): Don't bother to re-fetch
--- a/lisp/gnus/gnus-start.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/gnus/gnus-start.el	Tue May 25 09:35:50 2010 +0900
@@ -181,7 +181,7 @@
 should be less than this variable, are subscribed.  Groups with
 levels from `gnus-level-subscribed' (exclusive) upto this
 variable (inclusive) are unsubscribed.  See also
-`gnus-level-zombie', `gnus-level-killed' and the Info node `Group
+`gnus-level-zombie', `gnus-level-killed' and the Info node `(gnus)Group
 Levels' for details.")
 
 (defconst gnus-level-zombie 8
--- a/lisp/help-mode.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/help-mode.el	Tue May 25 09:35:50 2010 +0900
@@ -433,7 +433,9 @@
                     (let ((data (match-string 2)))
                       (save-match-data
                         (unless (string-match "^([^)]+)" data)
-                          (setq data (concat "(emacs)" data))))
+                          (setq data (concat "(emacs)" data)))
+			(setq data ;; possible newlines if para filled
+			      (replace-regexp-in-string "[ \t\n]+" " " data t t)))
                       (help-xref-button 2 'help-info data))))
                 ;; URLs
                 (save-excursion
--- a/lisp/image-mode.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/image-mode.el	Tue May 25 09:35:50 2010 +0900
@@ -448,7 +448,7 @@
 
 (defvar archive-superior-buffer)
 (defvar tar-superior-buffer)
-(declare-function image-refresh "image.c" (spec &optional frame))
+(declare-function image-flush "image.c" (spec &optional frame))
 
 (defun image-toggle-display-image ()
   "Show the image of the image file.
@@ -477,7 +477,7 @@
 	 (inhibit-read-only t)
 	 (buffer-undo-list t)
 	 (modified (buffer-modified-p)))
-    (image-refresh image)
+    (image-flush image)
     (let ((buffer-file-truename nil)) ; avoid changing dir mtime by lock_file
       (add-text-properties (point-min) (point-max) props)
       (restore-buffer-modified-p modified))
--- a/lisp/image.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/image.el	Tue May 25 09:35:50 2010 +0900
@@ -30,6 +30,7 @@
   "Image support."
   :group 'multimedia)
 
+(defalias 'image-refresh 'image-flush)
 
 (defconst image-type-header-regexps
   `(("\\`/[\t\n\r ]*\\*.*XPM.\\*/" . xpm)
--- a/lisp/indent.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/indent.el	Tue May 25 09:35:50 2010 +0900
@@ -431,7 +431,11 @@
 	(or (eolp)
 	    (indent-to column 0))
 	(forward-line 1))
-      (move-marker end nil))))
+      (move-marker end nil)))
+  ;; In most cases, reindenting modifies the buffer, but it may also
+  ;; leave it unmodified, in which case we have to deactivate the mark
+  ;; by hand.
+  (deactivate-mark))
 
 (defun indent-relative-maybe ()
   "Indent a new line like previous nonblank line.
--- a/lisp/isearch.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/isearch.el	Tue May 25 09:35:50 2010 +0900
@@ -156,6 +156,9 @@
 (defvar isearch-mode-hook nil
   "Function(s) to call after starting up an incremental search.")
 
+(defvar isearch-update-post-hook nil
+  "Function(s) to call after isearch has found matches in the buffer.")
+
 (defvar isearch-mode-end-hook nil
   "Function(s) to call after terminating an incremental search.
 When these functions are called, `isearch-mode-end-hook-quit'
@@ -460,7 +463,9 @@
     (define-key map "\M-\C-y" 'isearch-yank-char)
     (define-key map    "\C-y" 'isearch-yank-line)
 
-    (define-key map "\C-h" isearch-help-map)
+    (define-key map (char-to-string help-char) isearch-help-map)
+    (define-key map [help] isearch-help-map)
+    (define-key map [f1] isearch-help-map)
 
     (define-key map "\M-n" 'isearch-ring-advance)
     (define-key map "\M-p" 'isearch-ring-retreat)
@@ -868,7 +873,8 @@
     (isearch-lazy-highlight-new-loop))
   ;; We must prevent the point moving to the end of composition when a
   ;; part of the composition has just been searched.
-  (setq disable-point-adjustment t))
+  (setq disable-point-adjustment t)
+  (run-hooks 'isearch-update-post-hook))
 
 (defun isearch-done (&optional nopush edit)
   "Exit Isearch mode.
@@ -1476,14 +1482,10 @@
 	   (eq 'not-yanks search-upper-case))
       (setq string (downcase string)))
   (if isearch-regexp (setq string (regexp-quote string)))
-  (setq isearch-string (concat isearch-string string)
-	isearch-message
-	(concat isearch-message
-		(mapconcat 'isearch-text-char-description
-			   string ""))
-	;; Don't move cursor in reverse search.
-	isearch-yank-flag t)
-  (isearch-search-and-update))
+  ;; Don't move cursor in reverse search.
+  (setq isearch-yank-flag t)
+  (isearch-process-search-string
+   string (mapconcat 'isearch-text-char-description string "")))
 
 (defun isearch-yank-kill ()
   "Pull string from kill ring into search string."
@@ -1538,14 +1540,18 @@
   (interactive "p")
   (isearch-yank-internal (lambda () (forward-char arg) (point))))
 
+(declare-function subword-forward "subword" (&optional arg))
 (defun isearch-yank-word-or-char ()
-  "Pull next character or word from buffer into search string."
+  "Pull next character, subword or word from buffer into search string.
+Subword is used when `subword-mode' is activated. "
   (interactive)
   (isearch-yank-internal
    (lambda ()
      (if (or (= (char-syntax (or (char-after) 0)) ?w)
              (= (char-syntax (or (char-after (1+ (point))) 0)) ?w))
-         (forward-word 1)
+	 (if (and (boundp 'subword-mode) subword-mode)
+	     (subword-forward 1)
+	   (forward-word 1))
        (forward-char 1)) (point))))
 
 (defun isearch-yank-word ()
--- a/lisp/loadup.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/loadup.el	Tue May 25 09:35:50 2010 +0900
@@ -54,7 +54,7 @@
 	(equal (nth 3 command-line-args) "unidata-gen.el")
 	(equal (nth 4 command-line-args) "unidata-gen-files")
 	;; In case CANNOT_DUMP.
-	(equal (nth 0 command-line-args) "../src/bootstrap-emacs"))
+	(string-match "src/bootstrap-emacs" (nth 0 command-line-args)))
     (let ((dir (car load-path)))
       ;; We'll probably overflow the pure space.
       (setq purify-flag nil)
--- a/lisp/locate.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/locate.el	Tue May 25 09:35:50 2010 +0900
@@ -326,7 +326,7 @@
 	(locate-do-setup search-string)
 	))
     (and (not (string-equal (buffer-name) locate-buffer-name))
-	(switch-to-buffer-other-window locate-buffer-name))
+	(pop-to-buffer locate-buffer-name))
 
     (run-hooks 'dired-mode-hook)
     (dired-next-line 3)			;move to first matching file.
--- a/lisp/mh-e/ChangeLog	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/mh-e/ChangeLog	Tue May 25 09:35:50 2010 +0900
@@ -1,3 +1,10 @@
+2010-05-14  Peter S Galbraith  <psg@debian.org>
+
+	* mh-mime.el (mh-decode-message-subject): New function to decode
+	RFC2047 encoded Subject lines. Used for reply drafts.
+	* mh-comp.el (mh-compose-and-send-mail): Call
+	`mh-decode-message-subject' on (reply or forward) message drafts.
+
 2010-05-07  Chong Yidong  <cyd@stupidchicken.com>
 
 	* Version 23.2 released.
--- a/lisp/mh-e/mh-comp.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/mh-e/mh-comp.el	Tue May 25 09:35:50 2010 +0900
@@ -905,6 +905,9 @@
   (mh-identity-make-menu)
   (mh-identity-add-menu)
 
+  ;; Cleanup possibly RFC2047 encoded subject header
+  (mh-decode-message-subject)
+
   ;; Insert extra fields.
   (mh-insert-x-mailer)
   (mh-insert-x-face)
--- a/lisp/mh-e/mh-mime.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/mh-e/mh-mime.el	Tue May 25 09:35:50 2010 +0900
@@ -508,6 +508,15 @@
       (rfc2047-decode-region (point-min) (mh-mail-header-end)))))
 
 ;;;###mh-autoload
+(defun mh-decode-message-subject ()
+  "Decode RFC2047 encoded message header fields."
+  (when mh-decode-mime-flag
+    (save-excursion
+      (let ((buffer-read-only nil))
+        (rfc2047-decode-region (progn (mh-goto-header-field "subject:") (point))
+                               (progn (mh-header-field-end) (point)))))))
+
+;;;###mh-autoload
 (defun mh-mime-display (&optional pre-dissected-handles)
   "Display (and possibly decode) MIME handles.
 Optional argument, PRE-DISSECTED-HANDLES is a list of MIME
--- a/lisp/net/secrets.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/net/secrets.el	Tue May 25 09:35:50 2010 +0900
@@ -151,11 +151,11 @@
 
 (require 'dbus)
 
-(declare-function tree-widget-set-theme "tree-widget")
-(declare-function widget-create-child-and-convert "wid-edit")
-(declare-function widget-default-value-set "wid-edit")
-(declare-function widget-field-end "wid-edit")
-(declare-function widget-member "wid-edit")
+(autoload 'tree-widget-set-theme "tree-widget")
+(autoload 'widget-create-child-and-convert "wid-edit")
+(autoload 'widget-default-value-set "wid-edit")
+(autoload 'widget-field-end "wid-edit")
+(autoload 'widget-member "wid-edit")
 (defvar tree-widget-after-toggle-functions)
 
 (defvar secrets-enabled nil
@@ -563,7 +563,7 @@
 	(setq props (add-to-list
 		     'props
 		     (list :dict-entry
-			   (symbol-name (car attributes))
+			   (substring (symbol-name (car attributes)) 1)
 			   (cadr attributes))
 		     'append)
 	      attributes (cddr attributes)))
@@ -601,7 +601,7 @@
 	  (setq props (add-to-list
 		       'props
 		       (list :dict-entry
-			     (symbol-name (car attributes))
+			     (substring (symbol-name (car attributes)) 1)
 			     (cadr attributes))
 		       'append)
 		attributes (cddr attributes)))
@@ -656,7 +656,8 @@
   (let ((item-path (secrets-item-path collection item)))
     (unless (secrets-empty-path item-path)
       (mapcar
-       (lambda (attribute) (cons (intern (car attribute)) (cadr attribute)))
+       (lambda (attribute)
+	 (cons (intern (concat ":" (car attribute))) (cadr attribute)))
        (dbus-get-property
 	:session secrets-service item-path
 	secrets-interface-item "Attributes")))))
@@ -678,13 +679,10 @@
 ;;; Visualization.
 
 (define-derived-mode secrets-mode nil "Secrets"
-  "Major mode for presenting search results of a Xesam search.
+  "Major mode for presenting password entries retrieved by Security Service.
 In this mode, widgets represent the search results.
 
-\\{secrets-mode-map}
-Turning on Xesam mode runs the normal hook `xesam-mode-hook'.  It
-can be used to set `xesam-notify-function', which must a search
-engine specific, widget :notify function to visualize xesam:url."
+\\{secrets-mode-map}"
   ;; Keymap.
   (setq secrets-mode-map (copy-keymap special-mode-map))
   (set-keymap-parent secrets-mode-map widget-keymap)
@@ -707,19 +705,27 @@
 ;; keymap etc.  So we create a dummy buffer.  Stupid.
 (with-temp-buffer (secrets-mode))
 
-;;;###autoload
+;; We autoload `secrets-show-secrets' only on systems with D-Bus support.
+;;;###autoload(when (featurep 'dbusbind)
+;;;###autoload  (autoload 'secrets-show-secrets "secrets" nil t))
+
 (defun secrets-show-secrets ()
   "Display a list of collections from the Secret Service API.
 The collections are in tree view, that means they can be expanded
 to the corresponding secret items, which could also be expanded
 to their attributes."
   (interactive)
-  ;; Create the search buffer.
-  (with-current-buffer (get-buffer-create "*Secrets*")
-    (switch-to-buffer-other-window (current-buffer))
-    ;; Inialize buffer with `secrets-mode'.
-    (secrets-mode)
-    (secrets-show-collections)))
+
+  ;; Check, whether the Secret Service API is enabled.
+  (if (null secrets-enabled)
+      (message "Secret Service not available")
+
+    ;; Create the search buffer.
+    (with-current-buffer (get-buffer-create "*Secrets*")
+      (switch-to-buffer-other-window (current-buffer))
+      ;; Inialize buffer with `secrets-mode'.
+      (secrets-mode)
+      (secrets-show-collections))))
 
 (defun secrets-show-collections ()
   "Show all available collections."
@@ -757,14 +763,14 @@
 	 (attributes (secrets-get-attributes coll item))
 	 ;; padding is needed to format attribute names.
 	 (padding
-	  (1+
-	   (apply
-	    'max
-	    (cons
-	     (length "password")
-	     (mapcar
-	      (lambda (attribute) (length (symbol-name (car attribute))))
-	      attributes))))))
+	  (apply
+	   'max
+	   (cons
+	    (1+ (length "password"))
+	    (mapcar
+	     ;; Atribute names have a leading ":", which will be suppressed.
+	     (lambda (attribute) (length (symbol-name (car attribute))))
+	     attributes)))))
     (cons
      ;; The password widget.
      `(editable-field :tag "password"
@@ -779,7 +785,7 @@
 				"%v\n"))
      (mapcar
       (lambda (attribute)
-	(let ((name (symbol-name (car attribute)))
+	(let ((name (substring (symbol-name (car attribute)) 1))
 	      (value (cdr attribute)))
 	  ;; The attribute widget.
 	  `(editable-field :tag ,name
--- a/lisp/net/tramp-fish.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/net/tramp-fish.el	Tue May 25 09:35:50 2010 +0900
@@ -149,8 +149,11 @@
 ;; parameter of `write-region'.  Transfer of binary data fails due to
 ;; Emacs' process input/output handling.
 
+;;; Code:
 
-;;; Code:
+(eval-when-compile
+  ;; Pacify byte-compiler.
+  (require 'cl))
 
 (require 'tramp)
 (require 'tramp-cache)
@@ -487,13 +490,13 @@
        v 'file-error
        "Cannot make local copy of non-existing file `%s'" filename))
     (let ((tmpfile (tramp-compat-make-temp-file filename)))
-      (tramp-message v 4 "Fetching %s to tmp file %s..." filename tmpfile)
-      (when (tramp-fish-retrieve-data v)
-	;; Save file
-	(with-current-buffer (tramp-get-buffer v)
-	  (write-region (point-min) (point-max) tmpfile))
-	(tramp-message v 4 "Fetching %s to tmp file %s...done" filename tmpfile)
-	tmpfile))))
+      (with-progress-reporter
+	  v 3 (format "Fetching %s to tmp file %s" filename tmpfile)
+	(when (tramp-fish-retrieve-data v)
+	  ;; Save file
+	  (with-current-buffer (tramp-get-buffer v)
+	    (write-region (point-min) (point-max) tmpfile))
+	  tmpfile)))))
 
 ;; This function should return "foo/" for directories and "bar" for
 ;; files.
@@ -591,17 +594,16 @@
 
       (let ((point (point))
 	    size)
-	(tramp-message v 4 "Fetching file %s..." filename)
-	(when (tramp-fish-retrieve-data v)
-	  ;; Insert file
-	  (insert
-	   (with-current-buffer (tramp-get-buffer v)
-	     (let ((beg (or beg (point-min)))
-		   (end (min (or end (point-max)) (point-max))))
-	       (setq size (- end beg))
-	       (buffer-substring beg end))))
-	  (goto-char point))
-	(tramp-message v 4 "Fetching file %s...done" filename)
+	(with-progress-reporter v 3 (format "Fetching file %s" filename)
+	  (when (tramp-fish-retrieve-data v)
+	    ;; Insert file
+	    (insert
+	     (with-current-buffer (tramp-get-buffer v)
+	       (let ((beg (or beg (point-min)))
+		     (end (min (or end (point-max)) (point-max))))
+		 (setq size (- end beg))
+		 (buffer-substring beg end))))
+	    (goto-char point)))
 
 	(list (expand-file-name filename) size)))))
 
@@ -1115,34 +1117,36 @@
 	(delete-process p))
       (setenv "TERM" tramp-terminal-type)
       (setenv "PS1" tramp-initial-end-of-output)
-      (tramp-message
-       vec 3 "Opening connection for %s@%s using %s..."
-       tramp-current-user tramp-current-host tramp-current-method)
+      (with-progress-reporter
+	  vec 3
+	  (format "Opening connection for %s@%s using %s"
+		  tramp-current-user tramp-current-host tramp-current-method)
 
-      (let* ((process-connection-type tramp-process-connection-type)
-	     (inhibit-eol-conversion nil)
-	     (coding-system-for-read 'binary)
-	     (coding-system-for-write 'binary)
-	     ;; This must be done in order to avoid our file name handler.
-	     (p (let ((default-directory
-			(tramp-compat-temporary-file-directory)))
-		  (start-process
-		   (or (tramp-get-connection-property vec "process-name" nil)
-		       (tramp-buffer-name vec))
-		   (tramp-get-connection-buffer vec)
-		   "ssh" "-l"
-		   (tramp-file-name-user vec)
-		   (tramp-file-name-host vec)))))
-	(tramp-message vec 6 "%s" (mapconcat 'identity (process-command p) " "))
+	(let* ((process-connection-type tramp-process-connection-type)
+	       (inhibit-eol-conversion nil)
+	       (coding-system-for-read 'binary)
+	       (coding-system-for-write 'binary)
+	       ;; This must be done in order to avoid our file name handler.
+	       (p (let ((default-directory
+			  (tramp-compat-temporary-file-directory)))
+		    (start-process
+		     (or (tramp-get-connection-property vec "process-name" nil)
+			 (tramp-buffer-name vec))
+		     (tramp-get-connection-buffer vec)
+		     "ssh" "-l"
+		     (tramp-file-name-user vec)
+		     (tramp-file-name-host vec)))))
+	  (tramp-message
+	   vec 6 "%s" (mapconcat 'identity (process-command p) " "))
 
-	;; Check whether process is alive.
-	(tramp-set-process-query-on-exit-flag p nil)
+	  ;; Check whether process is alive.
+	  (tramp-set-process-query-on-exit-flag p nil)
 
-	(tramp-process-actions p vec tramp-actions-before-shell 60)
-	(tramp-fish-send-command vec tramp-fish-start-fish-server-command)
-	(tramp-message
-	 vec 3
-	 "Found remote shell prompt on `%s'" (tramp-file-name-host vec))))))
+	  (tramp-process-actions p vec tramp-actions-before-shell 60)
+	  (tramp-fish-send-command vec tramp-fish-start-fish-server-command)
+	  (tramp-message
+	   vec 3
+	   "Found remote shell prompt on `%s'" (tramp-file-name-host vec)))))))
 
 (defun tramp-fish-send-command (vec command)
   "Send the COMMAND to connection VEC."
--- a/lisp/net/tramp-gvfs.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/net/tramp-gvfs.el	Tue May 25 09:35:50 2010 +0900
@@ -1067,65 +1067,58 @@
 	    (tramp-gvfs-object-path
 	     (tramp-make-tramp-file-name method user host ""))))
 
-      (if (zerop (length (tramp-file-name-user vec)))
-	  (tramp-message
-	   vec 3 "Opening connection for %s using %s..." host method)
-	(tramp-message
-	 vec 3 "Opening connection for %s@%s using %s..." user host method))
+      (with-progress-reporter
+	  vec 3
+	  (if (zerop (length user))
+	      (format "Opening connection for %s using %s" host method)
+	    (format "Opening connection for %s@%s using %s" user host method))
 
-      ;; Enable auth-sorce and password-cache.
-      (tramp-set-connection-property vec "first-password-request" t)
+	;; Enable auth-sorce and password-cache.
+	(tramp-set-connection-property vec "first-password-request" t)
 
-      ;; There will be a callback of "askPassword", when a password is
-      ;; needed.
-      (dbus-register-method
-       :session dbus-service-emacs object-path
-       tramp-gvfs-interface-mountoperation "askPassword"
-       'tramp-gvfs-handler-askpassword)
+	;; There will be a callback of "askPassword", when a password is
+	;; needed.
+	(dbus-register-method
+	 :session dbus-service-emacs object-path
+	 tramp-gvfs-interface-mountoperation "askPassword"
+	 'tramp-gvfs-handler-askpassword)
 
-      ;; There could be a callback of "askQuestion", when adding fingerprint.
-      (dbus-register-method
-       :session dbus-service-emacs object-path
-       tramp-gvfs-interface-mountoperation "askQuestion"
-       'tramp-gvfs-handler-askquestion)
+	;; There could be a callback of "askQuestion", when adding fingerprint.
+	(dbus-register-method
+	 :session dbus-service-emacs object-path
+	 tramp-gvfs-interface-mountoperation "askQuestion"
+	 'tramp-gvfs-handler-askquestion)
 
-      ;; The call must be asynchronously, because of the "askPassword"
-      ;; or "askQuestion"callbacks.
-      (with-tramp-dbus-call-method vec nil
-	:session tramp-gvfs-service-daemon tramp-gvfs-path-mounttracker
-	tramp-gvfs-interface-mounttracker "mountLocation"
-	`(:struct
-	  ,(dbus-string-to-byte-array "/")
-	  ,(tramp-gvfs-mount-spec vec))
-	(dbus-get-unique-name :session)
-	:object-path object-path)
+	;; The call must be asynchronously, because of the "askPassword"
+	;; or "askQuestion"callbacks.
+	(with-tramp-dbus-call-method vec nil
+	  :session tramp-gvfs-service-daemon tramp-gvfs-path-mounttracker
+	  tramp-gvfs-interface-mounttracker "mountLocation"
+	  `(:struct
+	    ,(dbus-string-to-byte-array "/")
+	    ,(tramp-gvfs-mount-spec vec))
+	  (dbus-get-unique-name :session)
+	  :object-path object-path)
 
-      ;; We must wait, until the mount is applied.  This will be
-      ;; indicated by the "mounted" signal, i.e. the "fuse-mountpoint"
-      ;; file property.
-      (with-timeout
-	  (60
-	   (if (zerop (length (tramp-file-name-user vec)))
+	;; We must wait, until the mount is applied.  This will be
+	;; indicated by the "mounted" signal, i.e. the "fuse-mountpoint"
+	;; file property.
+	(with-timeout
+	    (60
+	     (if (zerop (length (tramp-file-name-user vec)))
+		 (tramp-error
+		  vec 'file-error
+		  "Timeout reached mounting %s using %s" host method)
 	       (tramp-error
 		vec 'file-error
-		"Timeout reached mounting %s using %s" host method)
-	     (tramp-error
-	      vec 'file-error
-	      "Timeout reached mounting %s@%s using %s" user host method)))
-	(while (not (tramp-get-file-property vec "/" "fuse-mountpoint" nil))
-	  (read-event nil nil 0.1)))
+		"Timeout reached mounting %s@%s using %s" user host method)))
+	  (while (not (tramp-get-file-property vec "/" "fuse-mountpoint" nil))
+	    (read-event nil nil 0.1)))
 
-      ;; We set the connection property "started" in order to put the
-      ;; remote location into the cache, which is helpful for further
-      ;; completion.
-      (tramp-set-connection-property vec "started" t)
-
-      (if (zerop (length (tramp-file-name-user vec)))
-	  (tramp-message
-	   vec 3 "Opening connection for %s using %s...done" host method)
-	(tramp-message
-	 vec 3
-	 "Opening connection for %s@%s using %s...done" user host method)))))
+	;; We set the connection property "started" in order to put the
+	;; remote location into the cache, which is helpful for further
+	;; completion.
+	(tramp-set-connection-property vec "started" t)))))
 
 
 ;; D-Bus BLUEZ functions.
--- a/lisp/net/tramp-imap.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/net/tramp-imap.el	Tue May 25 09:35:50 2010 +0900
@@ -241,32 +241,31 @@
 	(t2 (and (tramp-tramp-file-p newname)
 		 (tramp-imap-file-name-p newname))))
 
-    (when (and (not ok-if-already-exists) (file-exists-p newname))
-      (with-parsed-tramp-file-name (if t1 filename newname) nil
+    (with-parsed-tramp-file-name (if t1 filename newname) nil
+      (when (and (not ok-if-already-exists) (file-exists-p newname))
 	(tramp-error
-	 v 'file-already-exists "File %s already exists" newname)))
+	 v 'file-already-exists "File %s already exists" newname))
 
-    (with-parsed-tramp-file-name (if t1 filename newname) nil
-      (tramp-message v 0 "Transferring %s to %s..." filename newname))
+      (with-progress-reporter
+	  v 0 (format "%s %s to %s"
+		      (if (eq op 'copy) "Copying" "Renaming")
+		      filename newname)
 
-    ;; We just make a local copy of FILENAME, and write it then to
-    ;; NEWNAME.  This must be optimized, when both files are located
-    ;; on the same IMAP server.
-    (with-temp-buffer
-      (if (and t1 t2)
-	  ;; We don't encrypt.
-	  (with-parsed-tramp-file-name newname nil
-	    (insert (tramp-imap-get-file filename nil))
-	    (tramp-imap-put-file
-	     v (current-buffer)
-	     (tramp-imap-file-name-name v)
-	     nil nil (nth 7 (file-attributes filename))))
-	;; One of them is not located on a IMAP mailbox.
-	(insert-file-contents filename)
-	(write-region (point-min) (point-max) newname)))
-
-    (with-parsed-tramp-file-name (if t1 filename newname) nil
-      (tramp-message v 0 "Transferring %s to %s...done" filename newname))
+	;; We just make a local copy of FILENAME, and write it then to
+	;; NEWNAME.  This must be optimized, when both files are
+	;; located on the same IMAP server.
+	(with-temp-buffer
+	  (if (and t1 t2)
+	      ;; We don't encrypt.
+	      (with-parsed-tramp-file-name newname v1
+		(insert (tramp-imap-get-file filename nil))
+		(tramp-imap-put-file
+		 v1 (current-buffer)
+		 (tramp-imap-file-name-name v1)
+		 nil nil (nth 7 (file-attributes filename))))
+	    ;; One of them is not located on a IMAP mailbox.
+	    (insert-file-contents filename)
+	    (write-region (point-min) (point-max) newname)))))
 
     (when (eq op 'rename)
       (tramp-compat-delete-file filename 'force))))
@@ -505,17 +504,16 @@
 	 v 'file-error "File `%s' not found on remote host" filename)
       (let ((point (point))
 	    size data)
-	(tramp-message v 4 "Fetching file %s..." filename)
-	(insert (tramp-imap-get-file filename t))
-	(setq size (- (point) point))
+	(with-progress-reporter v 3 (format "Fetching file %s" filename)
+	  (insert (tramp-imap-get-file filename t))
+	  (setq size (- (point) point))
 ;;; TODO: handle ranges.
 ;;; 	       (let ((beg (or beg (point-min)))
 ;;; 		   (end (min (or end (point-max)) (point-max))))
 ;;; 		 (setq size (- end beg))
 ;;; 	       (buffer-substring beg end))
-	(goto-char point)
-	(tramp-message v 4 "Fetching file %s...done" filename)
-	(list (expand-file-name filename) size)))))
+	  (goto-char point)
+	  (list (expand-file-name filename) size))))))
 
 (defun tramp-imap-handle-file-exists-p (filename)
   "Like `file-exists-p' for Tramp files."
@@ -588,12 +586,12 @@
        v 'file-error
        "Cannot make local copy of non-existing file `%s'" filename))
     (let ((tmpfile (tramp-compat-make-temp-file filename)))
-      (tramp-message v 4 "Fetching %s to tmp file %s..." filename tmpfile)
-      (with-temp-buffer
-	(insert-file-contents filename)
- 	(write-region (point-min) (point-max) tmpfile)
- 	(tramp-message v 4 "Fetching %s to tmp file %s...done" filename tmpfile)
- 	tmpfile))))
+      (with-progress-reporter
+	  v 3 (format "Fetching %s to tmp file %s" filename tmpfile)
+	(with-temp-buffer
+	  (insert-file-contents filename)
+	  (write-region (point-min) (point-max) tmpfile)
+	  tmpfile)))))
 
 (defun tramp-imap-put-file
   (vec filename-or-buffer &optional subject inode encode size)
--- a/lisp/net/tramp.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/net/tramp.el	Tue May 25 09:35:50 2010 +0900
@@ -334,6 +334,7 @@
     ("scp"   (tramp-login-program        "ssh")
              (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
 					  ("-e" "none")))
+	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "scp")
 	     (tramp-copy-args            (("-P" "%p") ("-p" "%k")
@@ -349,6 +350,7 @@
     ("scp1"  (tramp-login-program        "ssh")
              (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
 					  ("-1" "-e" "none")))
+	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "scp")
 	     (tramp-copy-args            (("-1") ("-P" "%p") ("-p" "%k")
@@ -364,6 +366,7 @@
     ("scp2"  (tramp-login-program        "ssh")
              (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
 					  ("-2" "-e" "none")))
+	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "scp")
 	     (tramp-copy-args            (("-2") ("-P" "%p") ("-p" "%k")
@@ -399,6 +402,7 @@
     ("sftp"  (tramp-login-program        "ssh")
              (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
 					  ("-e" "none")))
+	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "sftp")
 	     (tramp-copy-args            nil)
@@ -407,6 +411,7 @@
     ("rsync" (tramp-login-program        "ssh")
              (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
 					  ("-e" "none")))
+	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "rsync")
 	     (tramp-copy-args            (("-e" "ssh") ("-t" "%k") ("-r")))
@@ -420,6 +425,7 @@
 					  ("-o" "ControlPath=%t.%%r@%%h:%%p")
 					  ("-o" "ControlMaster=yes")
 					  ("-e" "none")))
+	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "rsync")
 	     (tramp-copy-args            (("-t" "%k") ("-r")))
@@ -449,6 +455,7 @@
     ("ssh"   (tramp-login-program        "ssh")
              (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
 					  ("-e" "none")))
+	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         nil)
 	     (tramp-copy-args            nil)
@@ -462,6 +469,7 @@
     ("ssh1"  (tramp-login-program        "ssh")
              (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
 					  ("-1" "-e" "none")))
+	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         nil)
 	     (tramp-copy-args            nil)
@@ -475,6 +483,7 @@
     ("ssh2"  (tramp-login-program        "ssh")
              (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
 					  ("-2" "-e" "none")))
+	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         nil)
 	     (tramp-copy-args            nil)
@@ -489,6 +498,7 @@
              (tramp-login-program        "ssh1")
 	     (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
 					  ("-e" "none")))
+	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         nil)
 	     (tramp-copy-args            nil)
@@ -539,6 +549,7 @@
 					  ("-o" "ControlPath=%t.%%r@%%h:%%p")
 					  ("-o" "ControlMaster=yes")
 					  ("-e" "none")))
+	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "scp")
 	     (tramp-copy-args            (("-P" "%p") ("-p" "%k") ("-q")
@@ -554,6 +565,7 @@
     ("scpx"  (tramp-login-program        "ssh")
              (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
 					  ("-e" "none" "-t" "-t" "/bin/sh")))
+	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "scp")
 	     (tramp-copy-args            (("-p" "%k")))
@@ -567,6 +579,7 @@
     ("sshx"  (tramp-login-program        "ssh")
              (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
 					  ("-e" "none" "-t" "-t" "/bin/sh")))
+	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         nil)
 	     (tramp-copy-args            nil)
@@ -672,6 +685,11 @@
     \"%t\" is replaced by the temporary file name produced with
     `tramp-make-tramp-temp-file'.  \"%k\" indicates the keep-date
     parameter of a program, if exists.
+  * `tramp-async-args'
+    When an asynchronous process is started, we know already that
+    the connection works.  Therefore, we can pass additional
+    parameters to suppress diagnostic messages, in order not to
+    tamper the process output.
   * `tramp-copy-program'
     This specifies the name of the program to use for remotely copying
     the file; this might be the absolute filename of rcp or the name of
@@ -3641,85 +3659,86 @@
 		      (apply 'file-selinux-context (list filename))))
 	pr tm)
 
-    (when (and (not ok-if-already-exists) (file-exists-p newname))
-      (with-parsed-tramp-file-name (if t1 filename newname) nil
+    (with-parsed-tramp-file-name (if t1 filename newname) nil
+      (when (and (not ok-if-already-exists) (file-exists-p newname))
 	(tramp-error
-	 v 'file-already-exists "File %s already exists" newname)))
-
-    (with-parsed-tramp-file-name (if t1 filename newname) nil
+	 v 'file-already-exists "File %s already exists" newname))
+
       (with-progress-reporter
-	  v 0 (format "Transferring %s to %s" filename newname)
-
-       (cond
-	;; Both are Tramp files.
-	((and t1 t2)
-	 (with-parsed-tramp-file-name filename v1
-	   (with-parsed-tramp-file-name newname v2
-	     (cond
-	      ;; Shortcut: if method, host, user are the same for both
-	      ;; files, we invoke `cp' or `mv' on the remote host
-	      ;; directly.
-	      ((tramp-equal-remote filename newname)
-	       (tramp-do-copy-or-rename-file-directly
-		op filename newname
-		ok-if-already-exists keep-date preserve-uid-gid))
-
-	      ;; Try out-of-band operation.
-	      ((tramp-method-out-of-band-p
-		v1 (nth 7 (file-attributes filename)))
-	       (tramp-do-copy-or-rename-file-out-of-band
-		op filename newname keep-date))
-
-	      ;; No shortcut was possible.  So we copy the
-	      ;; file first.  If the operation was `rename', we go
-	      ;; back and delete the original file (if the copy was
-	      ;; successful).  The approach is simple-minded: we
-	      ;; create a new buffer, insert the contents of the
-	      ;; source file into it, then write out the buffer to
-	      ;; the target file.  The advantage is that it doesn't
-	      ;; matter which filename handlers are used for the
-	      ;; source and target file.
-	      (t
-	       (tramp-do-copy-or-rename-file-via-buffer
-		op filename newname keep-date))))))
-
-	;; One file is a Tramp file, the other one is local.
-	((or t1 t2)
-	 (cond
-	  ;; Fast track on local machine.
-	  ((tramp-local-host-p v)
-	   (tramp-do-copy-or-rename-file-directly
-	    op filename newname
-	    ok-if-already-exists keep-date preserve-uid-gid))
-
-	  ;; If the Tramp file has an out-of-band method, the corresponding
-	  ;; copy-program can be invoked.
-	  ((tramp-method-out-of-band-p v (nth 7 (file-attributes filename)))
-	   (tramp-do-copy-or-rename-file-out-of-band
-	    op filename newname keep-date))
-
-	  ;; Use the inline method via a Tramp buffer.
-	  (t (tramp-do-copy-or-rename-file-via-buffer
-	      op filename newname keep-date))))
-
-	(t
-	 ;; One of them must be a Tramp file.
-	 (error "Tramp implementation says this cannot happen")))
-
-       ;; Handle `preserve-selinux-context'.
-       (when context (apply 'set-file-selinux-context (list newname context)))
-
-       ;; In case of `rename', we must flush the cache of the source file.
-       (when (and t1 (eq op 'rename))
-	 (with-parsed-tramp-file-name filename v1
-	   (tramp-flush-file-property v1 (file-name-directory localname))
-	   (tramp-flush-file-property v1 localname)))
-
-       ;; When newname did exist, we have wrong cached values.
-       (when t2
-	 (with-parsed-tramp-file-name newname v2
-	   (tramp-flush-file-property v2 (file-name-directory localname))
-	   (tramp-flush-file-property v2 localname)))))))
+	  v 0 (format "%s %s to %s"
+		      (if (eq op 'copy) "Copying" "Renaming")
+		      filename newname)
+
+	(cond
+	 ;; Both are Tramp files.
+	 ((and t1 t2)
+	  (with-parsed-tramp-file-name filename v1
+	    (with-parsed-tramp-file-name newname v2
+	      (cond
+	       ;; Shortcut: if method, host, user are the same for
+	       ;; both files, we invoke `cp' or `mv' on the remote
+	       ;; host directly.
+	       ((tramp-equal-remote filename newname)
+		(tramp-do-copy-or-rename-file-directly
+		 op filename newname
+		 ok-if-already-exists keep-date preserve-uid-gid))
+
+	       ;; Try out-of-band operation.
+	       ((tramp-method-out-of-band-p
+		 v1 (nth 7 (file-attributes filename)))
+		(tramp-do-copy-or-rename-file-out-of-band
+		 op filename newname keep-date))
+
+	       ;; No shortcut was possible.  So we copy the file
+	       ;; first.  If the operation was `rename', we go back
+	       ;; and delete the original file (if the copy was
+	       ;; successful).  The approach is simple-minded: we
+	       ;; create a new buffer, insert the contents of the
+	       ;; source file into it, then write out the buffer to
+	       ;; the target file.  The advantage is that it doesn't
+	       ;; matter which filename handlers are used for the
+	       ;; source and target file.
+	       (t
+		(tramp-do-copy-or-rename-file-via-buffer
+		 op filename newname keep-date))))))
+
+	 ;; One file is a Tramp file, the other one is local.
+	 ((or t1 t2)
+	  (cond
+	   ;; Fast track on local machine.
+	   ((tramp-local-host-p v)
+	    (tramp-do-copy-or-rename-file-directly
+	     op filename newname
+	     ok-if-already-exists keep-date preserve-uid-gid))
+
+	   ;; If the Tramp file has an out-of-band method, the
+	   ;; corresponding copy-program can be invoked.
+	   ((tramp-method-out-of-band-p v (nth 7 (file-attributes filename)))
+	    (tramp-do-copy-or-rename-file-out-of-band
+	     op filename newname keep-date))
+
+	   ;; Use the inline method via a Tramp buffer.
+	   (t (tramp-do-copy-or-rename-file-via-buffer
+	       op filename newname keep-date))))
+
+	 (t
+	  ;; One of them must be a Tramp file.
+	  (error "Tramp implementation says this cannot happen")))
+
+	;; Handle `preserve-selinux-context'.
+	(when context (apply 'set-file-selinux-context (list newname context)))
+
+	;; In case of `rename', we must flush the cache of the source file.
+	(when (and t1 (eq op 'rename))
+	  (with-parsed-tramp-file-name filename v1
+	    (tramp-flush-file-property v1 (file-name-directory localname))
+	    (tramp-flush-file-property v1 localname)))
+
+	;; When newname did exist, we have wrong cached values.
+	(when t2
+	  (with-parsed-tramp-file-name newname v2
+	    (tramp-flush-file-property v2 (file-name-directory localname))
+	    (tramp-flush-file-property v2 localname)))))))
 
 (defun tramp-do-copy-or-rename-file-via-buffer (op filename newname keep-date)
   "Use an Emacs buffer to copy or rename a file.
@@ -4752,7 +4771,7 @@
 	   (rem-enc
 	    (save-excursion
 	      (with-progress-reporter
-	       v 5 (format "Encoding remote file %s" filename)
+	       v 3 (format "Encoding remote file %s" filename)
 	       (tramp-barf-unless-okay
 		v (format rem-enc (tramp-shell-quote-argument localname))
 		"Encoding remote file failed"))
@@ -5323,46 +5342,50 @@
 ;; any other remote command.
 (defun tramp-handle-vc-registered (file)
   "Like `vc-registered' for Tramp files."
-  (with-parsed-tramp-file-name file nil
-
-    ;; There could be new files, created by the vc backend.  We cannot
-    ;; reuse the old cache entries, therefore.
-    (let (tramp-vc-registered-file-names
-	  (tramp-cache-inhibit-cache (current-time))
-	  (file-name-handler-alist
-	   `((,tramp-file-name-regexp . tramp-vc-file-name-handler))))
-
-      ;; Here we collect only file names, which need an operation.
-      (tramp-run-real-handler 'vc-registered (list file))
-      (tramp-message v 10 "\n%s" tramp-vc-registered-file-names)
-
-      ;; Send just one command, in order to fill the cache.
-      (when tramp-vc-registered-file-names
-	(tramp-maybe-send-script
-	 v
-	 (format tramp-vc-registered-read-file-names
-		 (tramp-get-file-exists-command v)
-		 (format "%s -r" (tramp-get-test-command v)))
-	 "tramp_vc_registered_read_file_names")
-
-	(dolist
-	    (elt
-	     (tramp-send-command-and-read
-	      v
-	      (format
-	       "tramp_vc_registered_read_file_names %s"
-	       (mapconcat 'tramp-shell-quote-argument
-			  tramp-vc-registered-file-names
-			  " "))))
-
-	  (tramp-set-file-property v (car elt) (cadr elt) (cadr (cdr elt))))))
-
-    ;; Second run.  Now all `file-exists-p' or `file-readable-p' calls
-    ;; shall be answered from the file cache.
-    ;; We unset `process-file-side-effects' in order to keep the cache
-    ;; when `process-file' calls appear.
-    (let (process-file-side-effects)
-      (tramp-run-real-handler 'vc-registered (list file)))))
+  (with-temp-message ""
+    (with-parsed-tramp-file-name file nil
+      (with-progress-reporter
+	  v 3 (format "Checking `vc-registered' for %s" file)
+
+	;; There could be new files, created by the vc backend.  We
+	;; cannot reuse the old cache entries, therefore.
+	(let (tramp-vc-registered-file-names
+	      (tramp-cache-inhibit-cache (current-time))
+	      (file-name-handler-alist
+	       `((,tramp-file-name-regexp . tramp-vc-file-name-handler))))
+
+	  ;; Here we collect only file names, which need an operation.
+	  (tramp-run-real-handler 'vc-registered (list file))
+	  (tramp-message v 10 "\n%s" tramp-vc-registered-file-names)
+
+	  ;; Send just one command, in order to fill the cache.
+	  (when tramp-vc-registered-file-names
+	    (tramp-maybe-send-script
+	     v
+	     (format tramp-vc-registered-read-file-names
+		     (tramp-get-file-exists-command v)
+		     (format "%s -r" (tramp-get-test-command v)))
+	     "tramp_vc_registered_read_file_names")
+
+	    (dolist
+		(elt
+		 (tramp-send-command-and-read
+		  v
+		  (format
+		   "tramp_vc_registered_read_file_names %s"
+		   (mapconcat 'tramp-shell-quote-argument
+			      tramp-vc-registered-file-names
+			      " "))))
+
+	      (tramp-set-file-property
+	       v (car elt) (cadr elt) (cadr (cdr elt))))))
+
+	;; Second run.  Now all `file-exists-p' or `file-readable-p'
+	;; calls shall be answered from the file cache.  We unset
+	;; `process-file-side-effects' in order to keep the cache when
+	;; `process-file' calls appear.
+	(let (process-file-side-effects)
+	  (tramp-run-real-handler 'vc-registered (list file)))))))
 
 ;;;###autoload
 (progn (defun tramp-run-real-handler (operation args)
@@ -7380,6 +7403,7 @@
 connection if a previous connection has died for some reason."
   (catch 'uname-changed
     (let ((p (tramp-get-connection-process vec))
+	  (process-name (tramp-get-connection-property vec "process-name" nil))
 	  (process-environment (copy-sequence process-environment)))
 
       ;; If too much time has passed since last command was sent, look
@@ -7413,126 +7437,135 @@
 	;; We call `tramp-get-buffer' in order to get a debug buffer for
 	;; messages from the beginning.
 	(tramp-get-buffer vec)
-	(if (zerop (length (tramp-file-name-user vec)))
+	(with-progress-reporter
+	    vec 3
+	    (if (zerop (length (tramp-file-name-user vec)))
+		(format "Opening connection for %s using %s"
+			(tramp-file-name-host vec)
+			(tramp-file-name-method vec))
+	      (format "Opening connection for %s@%s using %s"
+		      (tramp-file-name-user vec)
+		      (tramp-file-name-host vec)
+		      (tramp-file-name-method vec)))
+
+	  ;; Start new process.
+	  (when (and p (processp p))
+	    (delete-process p))
+	  (setenv "TERM" tramp-terminal-type)
+	  (setenv "LC_ALL" "C")
+	  (setenv "PROMPT_COMMAND")
+	  (setenv "PS1" tramp-initial-end-of-output)
+	  (let* ((target-alist (tramp-compute-multi-hops vec))
+		 (process-connection-type tramp-process-connection-type)
+		 (process-adaptive-read-buffering nil)
+		 (coding-system-for-read nil)
+		 ;; This must be done in order to avoid our file name handler.
+		 (p (let ((default-directory
+			    (tramp-compat-temporary-file-directory)))
+		      (start-process
+		       (or process-name (tramp-buffer-name vec))
+		       (tramp-get-connection-buffer vec)
+		       tramp-encoding-shell))))
+
 	    (tramp-message
-	     vec 3 "Opening connection for %s using %s"
-	     (tramp-file-name-host vec)
-	     (tramp-file-name-method vec))
-	  (tramp-message
-	   vec 3 "Opening connection for %s@%s using %s"
-	   (tramp-file-name-user vec)
-	   (tramp-file-name-host vec)
-	   (tramp-file-name-method vec)))
-
-	;; Start new process.
-	(when (and p (processp p))
-	  (delete-process p))
-	(setenv "TERM" tramp-terminal-type)
-	(setenv "LC_ALL" "C")
-	(setenv "PROMPT_COMMAND")
-	(setenv "PS1" tramp-initial-end-of-output)
-	(let* ((target-alist (tramp-compute-multi-hops vec))
-	       (process-connection-type tramp-process-connection-type)
-	       (process-adaptive-read-buffering nil)
-	       (coding-system-for-read nil)
-	       ;; This must be done in order to avoid our file name handler.
-	       (p (let ((default-directory
-			  (tramp-compat-temporary-file-directory)))
-		    (start-process
-		     (or (tramp-get-connection-property vec "process-name" nil)
-			 (tramp-buffer-name vec))
-		     (tramp-get-connection-buffer vec)
-		     tramp-encoding-shell))))
-
-	  (tramp-message
-	   vec 6 "%s" (mapconcat 'identity (process-command p) " "))
-
-	  ;; Check whether process is alive.
-	  (tramp-set-process-query-on-exit-flag p nil)
-	  (with-progress-reporter vec 3 "Waiting 60s for local shell to come up"
+	     vec 6 "%s" (mapconcat 'identity (process-command p) " "))
+
+	    ;; Check whether process is alive.
+	    (tramp-set-process-query-on-exit-flag p nil)
 	    (tramp-barf-if-no-shell-prompt
-	     p 60 "Couldn't find local shell prompt %s" tramp-encoding-shell))
-
-	  ;; Now do all the connections as specified.
-	  (while target-alist
-	    (let* ((hop (car target-alist))
-		   (l-method (tramp-file-name-method hop))
-		   (l-user (tramp-file-name-user hop))
-		   (l-host (tramp-file-name-host hop))
-		   (l-port nil)
-		   (login-program
-		    (tramp-get-method-parameter l-method 'tramp-login-program))
-		   (login-args
-		    (tramp-get-method-parameter l-method 'tramp-login-args))
-		   (gw-args
-		    (tramp-get-method-parameter l-method 'tramp-gw-args))
-		   (gw (tramp-get-file-property hop "" "gateway" nil))
-		   (g-method (and gw (tramp-file-name-method gw)))
-		   (g-user (and gw (tramp-file-name-user gw)))
-		   (g-host (and gw (tramp-file-name-host gw)))
-		   (command login-program)
-		   ;; We don't create the temporary file.  In fact, it
-		   ;; is just a prefix for the ControlPath option of
-		   ;; ssh; the real temporary file has another name, and
-		   ;; it is created and protected by ssh.  It is also
-		   ;; removed by ssh, when the connection is closed.
-		   (tmpfile
-		    (tramp-set-connection-property
-		     p "temp-file"
-		     (make-temp-name
-		      (expand-file-name
-		       tramp-temp-name-prefix
-		       (tramp-compat-temporary-file-directory)))))
-		   spec)
-
-	      ;; Add gateway arguments if necessary.
-	      (when (and gw gw-args)
-		(setq login-args (append login-args gw-args)))
-
-	      ;; Check for port number.  Until now, there's no need
-	      ;; for handling like method, user, host.
-	      (when (string-match tramp-host-with-port-regexp l-host)
+	     p 60 "Couldn't find local shell prompt %s" tramp-encoding-shell)
+
+	    ;; Now do all the connections as specified.
+	    (while target-alist
+	      (let* ((hop (car target-alist))
+		     (l-method (tramp-file-name-method hop))
+		     (l-user (tramp-file-name-user hop))
+		     (l-host (tramp-file-name-host hop))
+		     (l-port nil)
+		     (login-program
+		      (tramp-get-method-parameter
+		       l-method 'tramp-login-program))
+		     (login-args
+		      (tramp-get-method-parameter l-method 'tramp-login-args))
+		     (async-args
+		      (tramp-get-method-parameter l-method 'tramp-async-args))
+		     (gw-args
+		      (tramp-get-method-parameter l-method 'tramp-gw-args))
+		     (gw (tramp-get-file-property hop "" "gateway" nil))
+		     (g-method (and gw (tramp-file-name-method gw)))
+		     (g-user (and gw (tramp-file-name-user gw)))
+		     (g-host (and gw (tramp-file-name-host gw)))
+		     (command login-program)
+		     ;; We don't create the temporary file.  In fact,
+		     ;; it is just a prefix for the ControlPath option
+		     ;; of ssh; the real temporary file has another
+		     ;; name, and it is created and protected by ssh.
+		     ;; It is also removed by ssh, when the connection
+		     ;; is closed.
+		     (tmpfile
+		      (tramp-set-connection-property
+		       p "temp-file"
+		       (make-temp-name
+			(expand-file-name
+			 tramp-temp-name-prefix
+			 (tramp-compat-temporary-file-directory)))))
+		     spec)
+
+		;; Add arguments for asynchrononous processes.
+		(when (and process-name async-args)
+		  (setq login-args (append login-args async-args)))
+
+		;; Add gateway arguments if necessary.
+		(when (and gw gw-args)
+		  (setq login-args (append login-args gw-args)))
+
+		;; Check for port number.  Until now, there's no need
+		;; for handling like method, user, host.
+		(when (string-match tramp-host-with-port-regexp l-host)
 		(setq l-port (match-string 2 l-host)
 		      l-host (match-string 1 l-host)))
 
-	      ;; Set variables for computing the prompt for reading
-	      ;; password.  They can also be derived from a gateway.
-	      (setq tramp-current-method (or g-method l-method)
-		    tramp-current-user   (or g-user   l-user)
-		    tramp-current-host   (or g-host   l-host))
-
-	      ;; Replace login-args place holders.
-	      (setq
-	       l-host (or l-host "")
-	       l-user (or l-user "")
-	       l-port (or l-port "")
-	       spec (format-spec-make ?h l-host ?u l-user ?p l-port ?t tmpfile)
-	       command
-	       (concat
-		;; We do not want to see the trailing local prompt in
-		;; `start-file-process'.
-		(unless (memq system-type '(windows-nt)) "exec ")
-		command " "
-		(mapconcat
-		 (lambda (x)
-		   (setq x (mapcar (lambda (y) (format-spec y spec)) x))
-		   (unless (member "" x) (mapconcat 'identity x " ")))
-		 login-args " ")
-		;; Local shell could be a Windows COMSPEC.  It doesn't
-		;; know the ";" syntax, but we must exit always for
-		;; `start-file-process'.  "exec" does not work either.
-		(if (memq system-type '(windows-nt)) " && exit || exit")))
-
-	      ;; Send the command.
-	      (tramp-message vec 3 "Sending command `%s'" command)
-	      (tramp-send-command vec command t t)
-	      (tramp-process-actions p vec tramp-actions-before-shell 60)
-	      (tramp-message vec 3 "Found remote shell prompt on `%s'" l-host))
-	    ;; Next hop.
-	    (setq target-alist (cdr target-alist)))
-
-	  ;; Make initial shell settings.
-	  (tramp-open-connection-setup-interactive-shell p vec))))))
+		;; Set variables for computing the prompt for reading
+		;; password.  They can also be derived from a gateway.
+		(setq tramp-current-method (or g-method l-method)
+		      tramp-current-user   (or g-user   l-user)
+		      tramp-current-host   (or g-host   l-host))
+
+		;; Replace login-args place holders.
+		(setq
+		 l-host (or l-host "")
+		 l-user (or l-user "")
+		 l-port (or l-port "")
+		 spec (format-spec-make
+		       ?h l-host ?u l-user ?p l-port ?t tmpfile)
+		 command
+		 (concat
+		  ;; We do not want to see the trailing local prompt in
+		  ;; `start-file-process'.
+		  (unless (memq system-type '(windows-nt)) "exec ")
+		  command " "
+		  (mapconcat
+		   (lambda (x)
+		     (setq x (mapcar (lambda (y) (format-spec y spec)) x))
+		     (unless (member "" x) (mapconcat 'identity x " ")))
+		   login-args " ")
+		  ;; Local shell could be a Windows COMSPEC.  It
+		  ;; doesn't know the ";" syntax, but we must exit
+		  ;; always for `start-file-process'.  "exec" does not
+		  ;; work either.
+		  (if (memq system-type '(windows-nt)) " && exit || exit")))
+
+		;; Send the command.
+		(tramp-message vec 3 "Sending command `%s'" command)
+		(tramp-send-command vec command t t)
+		(tramp-process-actions p vec tramp-actions-before-shell 60)
+		(tramp-message
+		 vec 3 "Found remote shell prompt on `%s'" l-host))
+	      ;; Next hop.
+	      (setq target-alist (cdr target-alist)))
+
+	    ;; Make initial shell settings.
+	    (tramp-open-connection-setup-interactive-shell p vec)))))))
 
 (defun tramp-send-command (vec command &optional neveropen nooutput)
   "Send the COMMAND to connection VEC.
--- a/lisp/nxml/nxml-mode.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/nxml/nxml-mode.el	Tue May 25 09:35:50 2010 +0900
@@ -404,6 +404,7 @@
     (define-key map "\M-}" 'nxml-forward-paragraph)
     (define-key map "\M-h" 'nxml-mark-paragraph)
     (define-key map "\C-c\C-f" 'nxml-finish-element)
+    (define-key map "\C-c/" 'nxml-finish-element)
     (define-key map "\C-c\C-m" 'nxml-split-element)
     (define-key map "\C-c\C-b" 'nxml-balanced-close-start-tag-block)
     (define-key map "\C-c\C-i" 'nxml-balanced-close-start-tag-inline)
--- a/lisp/password-cache.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/password-cache.el	Tue May 25 09:35:50 2010 +0900
@@ -105,7 +105,7 @@
 
 (defun password-cache-remove (key)
   "Remove password indexed by KEY from password cache.
-This is typically run be a timer setup from `password-cache-add',
+This is typically run by a timer setup from `password-cache-add',
 but can be invoked at any time to forcefully remove passwords
 from the cache.  This may be useful when it has been detected
 that a password is invalid, so that `password-read' query the
--- a/lisp/progmodes/cc-engine.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/progmodes/cc-engine.el	Tue May 25 09:35:50 2010 +0900
@@ -2245,50 +2245,50 @@
 	    (setq cnt (1- cnt)))))
     (point)))
 
-(defun c-state-balance-parens-backwards (here top)
-  ;; Return the position of the opening paren/brace/bracket before HERE which
-  ;; matches the outermost close p/b/b between HERE and TOP, like this:
-  ;;
-  ;;      ......................................
-  ;;      |                                    |
-  ;;      (    [ ( ...........  )      ( )  ]  )
-  ;;      ^                 ^                       ^
-  ;;      |                 |                       |
-  ;;   return             HERE                     TOP
+(defun c-state-balance-parens-backwards (here- here+ top)
+  ;; Return the position of the opening paren/brace/bracket before HERE- which
+  ;; matches the outermost close p/b/b between HERE+ and TOP.  Except when
+  ;; there's a macro, HERE- and HERE+ are the same.  Like this:
+  ;;
+  ;;	  ............................................
+  ;;	  |				             |
+  ;;	  (    [ ( .........#macro.. )      ( )  ]  )
+  ;;	  ^		    ^	  ^			    ^
+  ;;	  |		    |	  |			    |
+  ;;   return		  HERE- HERE+			   TOP
   ;;
   ;; If there aren't enough opening paren/brace/brackets, return the position
-  ;; of the outermost one found, or HERE it there are none.  If there are no
-  ;; closeing p/b/bs between HERE and TOP, return HERE.  HERE and TOP must not
-  ;; be inside literals.  Only the accessible portion of the buffer will be
-  ;; scanned.
-
-  ;; PART 1: scan from `here' up to `top', accumulating ")"s which enclose
-  ;; `here'.  Go round the next loop each time we pass over such a ")".  These
-  ;; probably match "("s before `here'.
+  ;; of the outermost one found, or HERE- if there are none.  If there are no
+  ;; closeing p/b/bs between HERE+ and TOP, return HERE-.  HERE-/+ and TOP
+  ;; must not be inside literals.  Only the accessible portion of the buffer
+  ;; will be scanned.
+
+  ;; PART 1: scan from `here+' up to `top', accumulating ")"s which enclose
+  ;; `here'.  Go round the next loop each time we pass over such a ")".	 These
+  ;; probably match "("s before `here-'.
   (let (pos pa ren+1 lonely-rens)
     (save-excursion
       (save-restriction
 	(narrow-to-region (point-min) top) ; This can move point, sometimes.
-	(setq pos here)
+	(setq pos here+)
 	(c-safe
 	  (while
 	      (setq ren+1 (scan-lists pos 1 1)) ; might signal
 	    (setq lonely-rens (cons ren+1 lonely-rens)
 		  pos ren+1)))))
 
-      ;; PART 2: Scan back before `here' searching for the "("s
+      ;; PART 2: Scan back before `here-' searching for the "("s
       ;; matching/mismatching the ")"s found above. We only need to direct the
       ;; caller to scan when we've encountered unmatched right parens.
-      (when lonely-rens
-	(setq pos here)
-	(c-safe
-	  (while
-	      (and lonely-rens		; actual values aren't used.
-		   (setq pa (scan-lists pos -1 1)))
-	    (setq pos pa)
-	    (setq lonely-rens (cdr lonely-rens)))) ;)
-	)
-      pos))
+    (setq pos here-)
+    (when lonely-rens
+      (c-safe
+	(while
+	    (and lonely-rens		; actual values aren't used.
+		 (setq pa (scan-lists pos -1 1)))
+	  (setq pos pa)
+	  (setq lonely-rens (cdr lonely-rens)))))
+    pos))
 
 (defun c-parse-state-get-strategy (here good-pos)
   ;; Determine the scanning strategy for adjusting `c-parse-state', attempting
@@ -2746,6 +2746,7 @@
 	lit	    ; (START . END) of a literal containing some point.
 	here-lit-start here-lit-end	; bounds of literal containing `here'
 					; or `here' itself.
+	here- here+		     ; start/end of macro around HERE, or HERE
 	(here-bol (c-point 'bol here))
 	(too-far-back (max (- here c-state-cache-too-far) 1)))
 
@@ -2758,57 +2759,73 @@
     ;; At this stage, (> pos here);
     ;; (< (c-state-cache-top-lparen) here)  (or is nil).
 
-    ;; CASE 1: The top of the cache is a brace pair which now encloses `here'.
-    ;; As good-pos, return the address. of the "{".
-    (if (and (consp (car c-state-cache))
-	     (> (cdar c-state-cache) here))
-	;; Since we've no knowledge of what's inside these braces, we have no
-	;; alternative but to direct the caller to scan the buffer from the
-	;; opening brace.
-	(progn
-	  (setq pos (caar c-state-cache))
-	  (setcar c-state-cache pos)
-	  (list (1+ pos) pos t)) ; return value.  We've just converted a brace
-			         ; pair entry into a { entry, so the caller
-			         ; needs to search for a brace pair before the
-			         ; {.
-
-      ;; ;; `here' might be inside a literal.  Check for this.
-      (setq lit (c-state-literal-at here)
-	    here-lit-start (or (car lit) here)
-	    here-lit-end (or (cdr lit) here))
-
-      ;; `here' might be nested inside any depth of parens (or brackets but
-      ;; not braces).  Scan backwards to find the outermost such opening
-      ;; paren, if there is one.  This will be the scan position to return.
-      (save-restriction
-	(narrow-to-region cache-pos (point-max))
-	(setq pos (c-state-balance-parens-backwards here-lit-end pos)))
-
-      (if (< pos here-lit-start)
-	  ;; CASE 2: Address of outermost ( or [ which now encloses `here',
-	  ;; but didn't enclose the (previous) `c-state-cache-good-pos'.  If
-	  ;; there is a brace pair preceding this, it will already be in
-	  ;; `c-state-cache', unless there was a brace pair after it,
-	  ;; i.e. there'll only be one to scan for if we've just deleted one.
-	  (list pos (and dropped-cons pos) t) ; Return value.
-
-	;; `here' isn't enclosed in a (previously unrecorded) bracket/paren.
-	;; Further forward scanning isn't needed, but we still need to find a
-	;; GOOD-POS.  Step out of all enclosing "("s on HERE's line.
+    (cond
+     ((and (consp (car c-state-cache))
+	   (> (cdar c-state-cache) here))
+      ;; CASE 1: The top of the cache is a brace pair which now encloses
+      ;; `here'.  As good-pos, return the address. of the "{".  Since we've no
+      ;; knowledge of what's inside these braces, we have no alternative but
+      ;; to direct the caller to scan the buffer from the opening brace.
+      (setq pos (caar c-state-cache))
+      (setcar c-state-cache pos)
+      (list (1+ pos) pos t)) ; return value.  We've just converted a brace pair
+			     ; entry into a { entry, so the caller needs to
+			     ; search for a brace pair before the {.
+
+     ;; `here' might be inside a literal.  Check for this.
+     ((progn
+	(setq lit (c-state-literal-at here)
+	      here-lit-start (or (car lit) here)
+	      here-lit-end (or (cdr lit) here))
+	;; Has `here' just "newly entered" a macro?
+	(save-excursion
+	  (goto-char here-lit-start)
+	  (if (and (c-beginning-of-macro)
+		   (or (null c-state-old-cpp-beg)
+		       (not (= (point) c-state-old-cpp-beg))))
+	      (progn
+		(setq here- (point))
+		(c-end-of-macro)
+		(setq here+ (point)))
+	    (setq here- here-lit-start
+		  here+ here-lit-end)))
+
+	;; `here' might be nested inside any depth of parens (or brackets but
+	;; not braces).  Scan backwards to find the outermost such opening
+	;; paren, if there is one.  This will be the scan position to return.
+	(save-restriction
+	  (narrow-to-region cache-pos (point-max))
+	  (setq pos (c-state-balance-parens-backwards here- here+ pos)))
+	nil))				; for the cond
+
+     ((< pos here-lit-start)
+      ;; CASE 2: Address of outermost ( or [ which now encloses `here', but
+      ;; didn't enclose the (previous) `c-state-cache-good-pos'.  If there is
+      ;; a brace pair preceding this, it will already be in `c-state-cache',
+      ;; unless there was a brace pair after it, i.e. there'll only be one to
+      ;; scan for if we've just deleted one.
+      (list pos (and dropped-cons pos) t)) ; Return value.
+
+      ;; `here' isn't enclosed in a (previously unrecorded) bracket/paren.
+      ;; Further forward scanning isn't needed, but we still need to find a
+      ;; GOOD-POS.  Step out of all enclosing "("s on HERE's line.
+     ((progn
 	(save-restriction
 	  (narrow-to-region here-bol (point-max))
 	  (setq pos here-lit-start)
 	  (c-safe (while (setq pa (scan-lists pos -1 1))
 		    (setq pos pa))))	; might signal
-	(if (setq ren (c-safe-scan-lists pos -1 -1 too-far-back))
-	    ;; CASE 3: After a }/)/] before `here''s BOL.
-	    (list (1+ ren) (and dropped-cons pos) nil) ; Return value
-
-	  ;; CASE 4; Best of a bad job: BOL before `here-bol', or beginning of
-	  ;; literal containing it.
-	  (setq good-pos (c-state-lit-beg (c-point 'bopl here-bol)))
-	  (list good-pos (and dropped-cons good-pos) nil))))))
+	nil))				; for the cond
+
+     ((setq ren (c-safe-scan-lists pos -1 -1 too-far-back))
+       ;; CASE 3: After a }/)/] before `here''s BOL.
+      (list (1+ ren) (and dropped-cons pos) nil)) ; Return value
+
+     (t
+      ;; CASE 4; Best of a bad job: BOL before `here-bol', or beginning of
+      ;; literal containing it.
+      (setq good-pos (c-state-lit-beg (c-point 'bopl here-bol)))
+      (list good-pos (and dropped-cons good-pos) nil)))))
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
--- a/lisp/progmodes/f90.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/progmodes/f90.el	Tue May 25 09:35:50 2010 +0900
@@ -1008,7 +1008,7 @@
   :regexp "\\(?:[^[:word:]_`]\\|^\\)\\(`?[[:word:]_]+\\)[^[:word:]_]*")
 
 ;;;###autoload
-(defun f90-mode ()
+(define-derived-mode f90-mode prog-mode "F90"
   "Major mode for editing Fortran 90,95 code in free format.
 For fixed format code, use `fortran-mode'.
 
@@ -1065,13 +1065,9 @@
 
 Turning on F90 mode calls the value of the variable `f90-mode-hook'
 with no args, if that value is non-nil."
-  (interactive)
-  (kill-all-local-variables)
-  (setq major-mode 'f90-mode
-        mode-name "F90"
-        local-abbrev-table f90-mode-abbrev-table)
-  (set-syntax-table f90-mode-syntax-table)
-  (use-local-map f90-mode-map)
+  :group 'f90
+  :syntax-table f90-mode-syntax-table
+  :abbrev-table f90-mode-abbrev-table
   (set (make-local-variable 'indent-line-function) 'f90-indent-line)
   (set (make-local-variable 'indent-region-function) 'f90-indent-region)
   (set (make-local-variable 'require-final-newline) mode-require-final-newline)
@@ -1094,8 +1090,7 @@
        'f90-beginning-of-subprogram)
   (set (make-local-variable 'end-of-defun-function) 'f90-end-of-subprogram)
   (set (make-local-variable 'add-log-current-defun-function)
-       #'f90-current-defun)
-  (run-mode-hooks 'f90-mode-hook))
+       #'f90-current-defun))
 
 
 ;; Inline-functions.
--- a/lisp/progmodes/fortran.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/progmodes/fortran.el	Tue May 25 09:35:50 2010 +0900
@@ -778,7 +778,7 @@
 
 
 ;;;###autoload
-(defun fortran-mode ()
+(define-derived-mode fortran-mode prog-mode "Fortran"
   "Major mode for editing Fortran code in fixed format.
 For free format code, use `f90-mode'.
 
@@ -848,13 +848,9 @@
 
 Turning on Fortran mode calls the value of the variable `fortran-mode-hook'
 with no args, if that value is non-nil."
-  (interactive)
-  (kill-all-local-variables)
-  (setq major-mode 'fortran-mode
-        mode-name "Fortran"
-        local-abbrev-table fortran-mode-abbrev-table)
-  (set-syntax-table fortran-mode-syntax-table)
-  (use-local-map fortran-mode-map)
+  :group 'fortran
+  :syntax-table fortran-mode-syntax-table
+  :abbrev-table fortran-mode-abbrev-table
   (set (make-local-variable 'indent-line-function) 'fortran-indent-line)
   (set (make-local-variable 'indent-region-function)
        (lambda (start end)
@@ -906,8 +902,7 @@
        #'fortran-current-defun)
   (set (make-local-variable 'dabbrev-case-fold-search) 'case-fold-search)
   (set (make-local-variable 'gud-find-expr-function) 'fortran-gud-find-expr)
-  (add-hook 'hack-local-variables-hook 'fortran-hack-local-variables nil t)
-  (run-mode-hooks 'fortran-mode-hook))
+  (add-hook 'hack-local-variables-hook 'fortran-hack-local-variables nil t))
 
 
 (defun fortran-line-length (nchars &optional global)
--- a/lisp/progmodes/grep.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/progmodes/grep.el	Tue May 25 09:35:50 2010 +0900
@@ -781,12 +781,17 @@
 		  (file-name-nondirectory bn)))
 	 (default-alias
 	   (and fn
-		(let ((aliases grep-files-aliases)
+		(let ((aliases (remove (assoc "all" grep-files-aliases)
+				       grep-files-aliases))
 		      alias)
 		  (while aliases
 		    (setq alias (car aliases)
 			  aliases (cdr aliases))
-		    (if (string-match (wildcard-to-regexp (cdr alias)) fn)
+		    (if (string-match (mapconcat
+				       'wildcard-to-regexp
+				       (split-string (cdr alias) nil t)
+				       "\\|")
+				      fn)
 			(setq aliases nil)
 		      (setq alias nil)))
 		  (cdr alias))))
--- a/lisp/progmodes/octave-mod.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/progmodes/octave-mod.el	Tue May 25 09:35:50 2010 +0900
@@ -214,6 +214,7 @@
     (define-key map "\C-c\M-\C-d" 'octave-down-block)
     (define-key map "\C-c\M-\C-h" 'octave-mark-block)
     (define-key map "\C-c]" 'octave-close-block)
+    (define-key map "\C-c/" 'octave-close-block)
     (define-key map "\C-c\C-f" 'octave-insert-defun)
     (define-key map "\C-c\C-h" 'octave-help)
     (define-key map "\C-c\C-il" 'octave-send-line)
--- a/lisp/progmodes/subword.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/progmodes/subword.el	Tue May 25 09:35:50 2010 +0900
@@ -76,7 +76,7 @@
 ;; the old `c-forward-into-nomenclature' originally contributed by
 ;; Terry_Glanfield dot Southern at rxuk dot xerox dot com.
 
-;; TODO: ispell-word and subword oriented C-w in isearch.
+;; TODO: ispell-word.
 
 ;;; Code:
 
--- a/lisp/replace.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/replace.el	Tue May 25 09:35:50 2010 +0900
@@ -1980,6 +1980,9 @@
 	    (isearch-regexp regexp)
 	    (search-whitespace-regexp nil)
 	    (isearch-case-fold-search case-fold))
+	;; Set isearch-word to nil because word-replace is regexp-based,
+	;; so `isearch-search-fun' should not use `word-search-forward'.
+	(if (and isearch-word isearch-regexp) (setq isearch-word nil))
 	(isearch-lazy-highlight-new-loop range-beg range-end))))
 
 (defun replace-dehighlight ()
--- a/lisp/simple.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/simple.el	Tue May 25 09:35:50 2010 +0900
@@ -4539,6 +4539,9 @@
 	       (let ((goal-column 0)
 		     (line-move-visual nil))
 		 (and (line-move arg t)
+		      ;; With bidi reordering, we may not be at bol,
+		      ;; so make sure we are.
+		      (skip-chars-backward "^\n")
 		      (not (bobp))
 		      (progn
 			(while (and (not (bobp)) (invisible-p (1- (point))))
--- a/lisp/smerge-mode.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/smerge-mode.el	Tue May 25 09:35:50 2010 +0900
@@ -457,8 +457,8 @@
 
 (defun smerge-resolve (&optional safe)
   "Resolve the conflict at point intelligently.
-This relies on mode-specific knowledge and thus only works in
-some major modes.  Uses `smerge-resolve-function' to do the actual work."
+This relies on mode-specific knowledge and thus only works in some
+major modes.  Uses `smerge-resolve-function' to do the actual work."
   (interactive)
   (smerge-match-conflict)
   (smerge-remove-props (match-beginning 0) (match-end 0))
@@ -815,12 +815,12 @@
   This only matters if `smerge-refine-weight-hack' is nil.")
 
 (defvar smerge-refine-ignore-whitespace t
-  "If non-nil,Indicate that smerge-refine should try to ignore change in whitespace.")
+  "If non-nil, indicate that `smerge-refine' should try to ignore change in whitespace.")
 
 (defvar smerge-refine-weight-hack t
   "If non-nil, pass to diff as many lines as there are chars in the region.
 I.e. each atomic element (e.g. word) will be copied as many times (on different
-lines) as it has chars.  This has 2 advantages:
+lines) as it has chars.  This has two advantages:
 - if `diff' tries to minimize the number *lines* (rather than chars)
   added/removed, this adjust the weights so that adding/removing long
   symbols is considered correspondingly more costly.
@@ -919,8 +919,8 @@
   "Show fine differences in the two regions BEG1..END1 and BEG2..END2.
 PROPS is an alist of properties to put (via overlays) on the changes.
 If non-nil, PREPROC is called with no argument in a buffer that contains
-a copy of a region, just before preparing it to for `diff'.  It can be used to
-replace chars to try and eliminate some spurious differences."
+a copy of a region, just before preparing it to for `diff'.  It can be
+used to replace chars to try and eliminate some spurious differences."
   (let* ((buf (current-buffer))
          (pos (point))
          (file1 (make-temp-file "diff1"))
@@ -988,9 +988,9 @@
 
 (defun smerge-refine (&optional part)
   "Highlight the words of the conflict that are different.
-For 3-way conflicts, highlights only 2 of the 3 parts.
-A numeric argument PART can be used to specify which 2 parts;
-repeating the command will highlight other 2 parts."
+For 3-way conflicts, highlights only two of the three parts.
+A numeric argument PART can be used to specify which two parts;
+repeating the command will highlight other two parts."
   (interactive
    (if (integerp current-prefix-arg) (list current-prefix-arg)
      (smerge-match-conflict)
@@ -1161,7 +1161,7 @@
 
 (defun smerge-makeup-conflict (pt1 pt2 pt3 &optional pt4)
   "Insert diff3 markers to make a new conflict.
-Uses point and mark for 2 of the relevant positions and previous marks
+Uses point and mark for two of the relevant positions and previous marks
 for the other ones.
 By default, makes up a 2-way conflict,
 with a \\[universal-argument] prefix, makes up a 3-way conflict."
@@ -1184,7 +1184,7 @@
     (insert "<<<<<<< MINE\n"))
   (if smerge-mode nil (smerge-mode 1))
   (smerge-refine))
-      
+
 
 (defconst smerge-parsep-re
   (concat smerge-begin-re "\\|" smerge-end-re "\\|"
--- a/lisp/vc-dir.el	Tue May 25 09:32:24 2010 +0900
+++ b/lisp/vc-dir.el	Tue May 25 09:35:50 2010 +0900
@@ -1169,7 +1169,8 @@
 	  nil t nil nil)))))
   (unless backend
     (setq backend (vc-responsible-backend dir)))
-  (pop-to-buffer (vc-dir-prepare-status-buffer "*vc-dir*" dir backend))
+  (let (pop-up-windows)		      ; based on cvs-examine; bug#6204
+    (pop-to-buffer (vc-dir-prepare-status-buffer "*vc-dir*" dir backend)))
   (if (derived-mode-p 'vc-dir-mode)
       (vc-dir-refresh)
     ;; FIXME: find a better way to pass the backend to `vc-dir-mode'.
--- a/make-dist	Tue May 25 09:32:24 2010 +0900
+++ b/make-dist	Tue May 25 09:35:50 2010 +0900
@@ -121,8 +121,8 @@
 done
 
 ### Make sure we're running in the right place.
-if [ ! -d src -o ! -f src/lisp.h -o ! -d lisp -o ! -f lisp/version.el ]; then
-  echo "${progname}: Can't find \`src/lisp.h' and \`lisp/version.el'." >&2
+if [ ! -d src -o ! -f src/lisp.h -o ! -d lisp -o ! -f lisp/subr.el ]; then
+  echo "${progname}: Can't find \`src/lisp.h' and \`lisp/subr.el'." >&2
   echo "${progname} must be run in the top directory of the Emacs" >&2
   echo "distribution tree.  cd to that directory and try again." >&2
   exit 1
@@ -150,12 +150,12 @@
 fi
 
 ### Find out which version of Emacs this is.
-shortversion=`grep 'defconst[	 ]*emacs-version' lisp/version.el \
+shortversion=`grep 'char emacs_version' src/emacs.c \
 	 | sed -e 's/^.*"\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/'`
-version=`grep 'defconst[	 ]*emacs-version' lisp/version.el \
+version=`grep 'char emacs_version' src/emacs.c \
 	 | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'`
 if [ ! "${version}" ]; then
-  echo "${progname}: can't find current Emacs version in \`./lisp/version.el'" >&2
+  echo "${progname}: can't find current Emacs version in \`./src/emacs.c'" >&2
   exit 1
 fi
 
@@ -440,6 +440,7 @@
  ln [a-zA-Z]*.h ../${tempdir}/src
  ln [a-zA-Z]*.m ../${tempdir}/src
  ln [a-zA-Z]*.in ../${tempdir}/src
+ ln [a-zA-Z]*.mk ../${tempdir}/src
  ## If we ended up with a symlink, or if we did not get anything
  ## due to a cross-device symlink, copy the file.
  for file in [a-zA-Z]*.[hcs] [a-zA-Z]*.in; do
--- a/msdos/ChangeLog	Tue May 25 09:32:24 2010 +0900
+++ b/msdos/ChangeLog	Tue May 25 09:35:50 2010 +0900
@@ -1,3 +1,24 @@
+2010-05-21  Glenn Morris  <rgm@gnu.org>
+
+	* sed1v2.inp(@ns_frag@): Edit to nothing.
+
+	* sed1x.inp (OLDXMENU): Replace any initial value.
+	* sed1v2.inp (OLDXMENU): Edit to "nothing".
+
+	* sed1v2.inp (CANNOT_DUMP): Edit to no.
+
+2010-05-20  Glenn Morris  <rgm@gnu.org>
+
+	* sed1v2.inp (DEPFLAGS, deps_frag): Edit to empty.
+	(MKDEPDIR): Edit to ':'.
+
+2010-05-19  Glenn Morris  <rgm@gnu.org>
+
+	* sed2v2.inp (ORDINARY_LINK): Set here rather than in s/msdos.h.
+
+	* sed1v2.inp (LD): Edit to $(CC).
+	(YMF_PASS_LDFLAGS): Edit to `flags'.
+
 2010-05-18  Eli Zaretskii  <eliz@gnu.org>
 
 	* sed1x.inp: Add copyright notice.
--- a/msdos/mainmake.v2	Tue May 25 09:32:24 2010 +0900
+++ b/msdos/mainmake.v2	Tue May 25 09:35:50 2010 +0900
@@ -68,10 +68,10 @@
 version := ${shell sed -n -e '/(defconst emacs-version/s/^[^"]*\("[^"]*"\).*/\1/p' lisp/version.el}
 
 # Q: Do we need to bootstrap?
-# A: Only if we find admin/admin.el, i.e. we are building out of CVS,
-#    and src/b-emacs.exe does not exist.  This avoids building a
-#    bootstrap-emacs and recompiling Lisp files when building a
-#    pretest/release tarball.
+# A: Only if we find admin/admin.el, i.e. we are building out of 
+#    a VCS-checkout (not a release) and src/b-emacs.exe does not exist.
+#    This avoids building a bootstrap-emacs and recompiling Lisp files
+#    when building a pretest/release tarball.
 boot :=
 ifneq ($(wildcard admin/admin.el),)
 ifeq ($(wildcard src/b-emacs.exe),)
--- a/msdos/sed1v2.inp	Tue May 25 09:32:24 2010 +0900
+++ b/msdos/sed1v2.inp	Tue May 25 09:35:50 2010 +0900
@@ -55,6 +55,7 @@
 /^TEMACS_LDFLAGS2 *=/s/@TEMACS_LDFLAGS2@/$(LDFLAGS)/
 /^LIBS_SYSTEM *=/s/@LIBS_SYSTEM@//
 /^LIB_GCC *=/s/@LIB_GCC@/-Lgcc/
+/^LD *=/s/@LINKER@/$(CC)/
 /^LIB_STANDARD *=/s/@LIB_STANDARD@//
 /^LIB_MATH *=/s/@LIB_MATH@/-lm/
 /^LIBTIFF *=/s/@LIBTIFF@//
@@ -113,7 +114,7 @@
 /^WINDOW_SUPPORT *=/s/@WINDOW_SUPPORT@//
 /^LIBGPM *=/s/@LIBGPM@//
 /^EXEEXT *=/s/@EXEEXT@/.exe/
-/^OLDXMENU *=/s/@OLDXMENU@//
+/^OLDXMENU *=/s/@OLDXMENU@/nothing/
 /^LIBXMENU *=/s/@LIBXMENU@//
 /^LIBX_OTHER *=/s/@LIBX_OTHER@//
 /^GMALLOC_OBJ *=/s/@GMALLOC_OBJ@/gmalloc.o/
@@ -122,6 +123,9 @@
 /^PRE_ALLOC_OBJ *=/s/@PRE_ALLOC_OBJ@/lastfile.o/
 /^POST_ALLOC_OBJ *=/s/@POST_ALLOC_OBJ@/$(vmlimitobj)/
 /^UNEXEC_OBJ *=/s/@unexec@/unexec.o/
+/^CANNOT_DUMP *=/s/@cannot_dump@/no/
+/^DEPFLAGS *=/s/@DEPFLAGS@//
+/^MKDEPDIR *=/s/@MKDEPDIR@/:/
 /^version *=/s/@[^@\n]*@//
 /^M_FILE *=/s!@[^@\n]*@!m/intel386.h!
 /^S_FILE *=/s!@[^@\n]*@!s/msdos.h!
@@ -143,6 +147,9 @@
 /^	@: /d
 /^	-\{0,1\}ln -/s/ln -f/cp -pf/
 /^[ 	]touch /s/touch/djecho $@ >/
+s/@YMF_PASS_LDFLAGS@/flags/
+s/@deps_frag@//
+s/@ns_frag@//
 s/bootstrap-emacs/b-emacs/
 s/bootstrap-temacs/b-temacs/
 s/bootstrap-doc/b-doc/
--- a/msdos/sed1x.inp	Tue May 25 09:32:24 2010 +0900
+++ b/msdos/sed1x.inp	Tue May 25 09:35:50 2010 +0900
@@ -19,7 +19,7 @@
 s!^	cd \${oldXMenudir}; \${MAKE}.*$!	${MAKE} -C ${oldXMenudir}.!
 s!^	@true *$!	@rem!
 s/DOC/DOC-X/g
-/^OLDXMENU *=/s!= *!= ${oldXMenudir}libXMenu11.a!
+/^OLDXMENU *=/s!=.*!= ${oldXMenudir}libXMenu11.a!
 /^LIBXMENU *=/s!= *!= ${OLDXMENU}!
 /^LIBX_OTHER *=/s!= *!= ${LIBXT} ${LIBX_EXTRA}!
 /^OLDXMENU_TARGET *=/s!= *!= really-oldxmenu!
--- a/msdos/sed2v2.inp	Tue May 25 09:32:24 2010 +0900
+++ b/msdos/sed2v2.inp	Tue May 25 09:35:50 2010 +0900
@@ -52,6 +52,7 @@
 /^#undef HAVE_MKSTEMP *$/s/^.*$/#define HAVE_MKSTEMP 1/
 /^#undef HAVE_STRUCT_TM_TM_ZONE *$/s/^.*$/#define HAVE_STRUCT_TM_TM_ZONE 1/
 /^#undef HAVE_SYNC *$/s/^.*$/#define HAVE_SYNC 1/
+/^#undef ORDINARY_LINK/s/^.*$/#define ORDINARY_LINK 1/
 /^#undef PACKAGE_BUGREPORT/s/^.*$/#define PACKAGE_BUGREPORT ""/
 /^#undef PACKAGE_NAME/s/^.*$/#define PACKAGE_NAME ""/
 /^#undef PACKAGE_STRING/s/^.*$/#define PACKAGE_STRING ""/
--- a/src/.gdbinit	Tue May 25 09:32:24 2010 +0900
+++ b/src/.gdbinit	Tue May 25 09:35:50 2010 +0900
@@ -616,7 +616,7 @@
 end
 
 define prowlims
-  printf "start=%d,end=%d,reversed=%d,cont=%d,at_zv=%d\n", $arg0->start.pos.charpos, $arg0->end.pos.charpos, $arg0->reversed_p, $arg0->continued_p, $arg0->ends_at_zv_p
+  printf "edges=(%d,%d),r2l=%d,cont=%d,trunc=(%d,%d),at_zv=%d\n", $arg0->minpos.charpos, $arg0->maxpos.charpos, $arg0->reversed_p, $arg0->continued_p, $arg0->truncated_on_left_p, $arg0->truncated_on_right_p, $arg0->ends_at_zv_p
 end
 document prowlims
 Print important attributes of a glyph_row structure.
@@ -626,10 +626,13 @@
 define pmtxrows
   set $mtx = $arg0
   set $gl = $mtx->rows
-  set $glend = $mtx->rows + $mtx->nrows
+  set $glend = $mtx->rows + $mtx->nrows - 1
+  set $i = 0
   while ($gl < $glend)
+    printf "%d: ", $i
     prowlims $gl
     set $gl = $gl + 1
+    set $i = $i + 1
   end
 end
 document pmtxrows
--- a/src/ChangeLog	Tue May 25 09:32:24 2010 +0900
+++ b/src/ChangeLog	Tue May 25 09:35:50 2010 +0900
@@ -21,6 +21,139 @@
 	is at the last character of the current grapheme cluster when
 	CMP_IT->reversed_p is nonzero.
 
+2010-05-24  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* process.c (Fmake_network_process): Set :host to nil if it's not used.
+	Suggested by Masatake YAMATO <yamato@redhat.com>.
+
+2010-05-23  Eli Zaretskii  <eliz@gnu.org>
+
+	* dispextern.h (init_iterator): Sync prototype with changed
+	definition.
+
+2010-05-19  Eli Zaretskii  <eliz@gnu.org>
+
+	Redesign and reimplement bidi-aware edge positions of glyph rows.
+
+	* dispextern.h (struct glyph_row): New members minpos and maxpos.
+	(MATRIX_ROW_START_CHARPOS, MATRIX_ROW_START_BYTEPOS)
+	(MATRIX_ROW_END_CHARPOS, MATRIX_ROW_END_BYTEPOS): Reference minpos
+	and maxpos members instead of start.pos and end.pos, respectively.
+
+	* xdisp.c (display_line): Compare IT_CHARPOS with the position in
+	row->start.pos, rather than with MATRIX_ROW_START_CHARPOS.
+	(cursor_row_p): Use row->end.pos rather than MATRIX_ROW_END_CHARPOS.
+	(try_window_reusing_current_matrix, try_window_id):
+	Use ROW->minpos rather than ROW->start.pos.
+	(init_from_display_pos, init_iterator): Use EMACS_INT for
+	character and byte positions.
+	(find_row_edges): Rename from find_row_end.  Accept additional
+	arguments for minimum and maximum buffer positions seen by
+	display_line for this row.  Don't use iterator to find the
+	position following the maximum one; instead, increment the
+	position found by display_line directly.  Fix logic; eol_pos
+	should be tested before the rest.  Handle the case of characters
+	delivered from display vector (bug#6036).  Fix tests related to
+	it->method.  Handle the truncated_on_right_p rows.
+	(RECORD_MAX_MIN_POS): New macro.
+	(display_line): Use it to record the minimum and maximum buffer
+	positions for glyphs in the row being assembled.  Record the
+	position of the newline that terminates the line.  If word wrap is
+	in effect, restore minimum and maximum positions seen up to the
+	wrap point, when iterator returns to it.
+	(try_window_reusing_current_matrix): Give up if in bidi-reordered
+	row and cursor not already at point.  Restore original pre-bidi
+	code for unidirectional buffers.
+
+	* dispnew.c (increment_row_positions, check_matrix_invariants):
+	Increment and check row->start.pos and row->end.pos, in addition
+	to MATRIX_ROW_START_CHARPOS and MATRIX_ROW_END_CHARPOS.
+
+	* .gdbinit (prowlims): Display row->minpos and row->maxpos.
+	Display truncated_on_left_p and truncated_on_right_p flags.
+	Formatting fixes.
+	(pmtxrows): Display the ordinal number of each row.  Don't display
+	rows beyond the last one.
+
+	* bidi.c (bidi_cache_iterator_state): Don't zero out new_paragraph:
+	it is not copied by bidi_copy_it.
+
+2010-05-22  Eli Zaretskii  <eliz@gnu.org>
+
+	* w32.c (sys_write): Break writes into chunks smaller than 32MB.
+	(Bug#6237)
+
+2010-05-22  Chong Yidong  <cyd@stupidchicken.com>
+
+	* image.c (Fimage_flush): Rename from image-refresh.
+
+2010-05-21  Chong Yidong  <cyd@stupidchicken.com>
+
+	* xdisp.c (redisplay_internal): Clear caches even if redisplaying
+	just one window.
+
+	* image.c (Vimage_cache_eviction_delay): Decrease to 300.
+	(clear_image_cache): If the number of cached images is unusually
+	large, decrease the cache eviction delay (Bug#6230).
+
+2010-05-21  Glenn Morris  <rgm@gnu.org>
+
+	* Makefile.in (${ns_appdir}, ${ns_appbindir}Emacs, ns-app):
+	Move these rules to ns.mk.
+	* ns.mk: New file.
+
+	* Makefile.in (../src/$(OLDXMENU), $(OLDXMENU)): Always define rules.
+
+	* Makefile.in (CANNOT_DUMP): New, set by configure.
+	(emacs${EXEEXT}, bootstrap-emacs${EXEEXT}): Use $CANNOT_DUMP.
+
+2010-05-20  Juri Linkov  <juri@jurta.org>
+
+	* fileio.c (Fdelete_file): Change interative spec to use
+	`read-file-name' like in `find-file-read-args' where the default
+	value is `default-directory' instead of `buffer-file-name'.
+	http://lists.gnu.org/archive/html/emacs-devel/2010-05/msg00533.html
+
+2010-05-20  Kevin Ryde  <user42@zip.com.au>
+
+	* keyboard.c (Vlast_command, Vkeyboard_translate_table)
+	(Voverriding_terminal_local_map, Vsystem_key_alist)
+	(Vlocal_function_key_map): Fix manual link in docstring (Bug#6224).
+
+2010-05-20  Glenn Morris  <rgm@gnu.org>
+
+	* Makefile.in (DEPDIR): New constant.
+	(DEPFLAGS): Set with configure, not cpp.
+	(MKDEPDIR): New, set by configure.
+	(.c.o, .m.o, ecrt0.o): Use $MKDEPDIR.
+	(clean): Use $DEPDIR.
+	(deps_frag): Include from configure.
+	Move static/dynamic dependency stuff to deps.mk/autodeps.mk.
+	* deps.mk, autodeps.mk: New files, extracted from Makefile.in.
+
+	* bidi.c (bidi_cache_shrink, bidi_cache_iterator_state): Fix
+	reallocation of the cache.  (Bug#6210)
+
+2010-05-19  Glenn Morris  <rgm@gnu.org>
+
+	* s/msdos.h (ORDINARY_LINK): Move to sed2v2.inp.
+
+	* Makefile.in (LD, YMF_PASS_LDFLAGS): Set with configure, not cpp.
+	(GNULIB_VAR): Remove.
+	(LIBES): Use LIB_GCC instead of GNULIB_VAR.
+
+	* m/ibms390x.h (LINKER):
+	* m/macppc.h (LINKER) [GNU_LINUX]:
+	* s/aix4-2.h (ORDINARY_LINK):
+	* s/cygwin.h (LINKER):
+	* s/darwin.h (ORDINARY_LINK):
+	* s/gnu.h (ORDINARY_LINK):
+	* s/netbsd.h (LINKER):
+	* s/usg5-4.h (ORDINARY_LINK):
+	Move to configure.
+
+	* s/aix4-2.h (LINKER): Remove; this file sets ORDINARY_LINK.
+
 2010-05-18  Chong Yidong  <cyd@stupidchicken.com>
 
 	* character.c (Fstring, Funibyte_string): Use SAFE_ALLOCA to
@@ -120,6 +253,8 @@
 	* xdisp.c (Fcurrent_bidi_paragraph_direction): New function.
 	(syms_of_xdisp): Defsubr it.
 
+	* cmds.c (Fforward_char, Fbackward_char): Doc fix.
+
 	* Makefile.in: Fix MSDOS-related comments.
 
 2010-05-15  Glenn Morris  <rgm@gnu.org>
--- a/src/Makefile.in	Tue May 25 09:32:24 2010 +0900
+++ b/src/Makefile.in	Tue May 25 09:35:50 2010 +0900
@@ -124,6 +124,8 @@
 ## Where to find libgcc.a, if using gcc and necessary.
 LIB_GCC=@LIB_GCC@
 
+LD=@LINKER@
+
 ## May use $CRT_DIR.
 LIB_STANDARD=@LIB_STANDARD@
 
@@ -171,13 +173,20 @@
 ## Only used if HAVE_X_WINDOWS.
 LIBXT_OTHER=@LIBXT_OTHER@
 
-## Only used if HAVE_X11 && !USE_GTK.
-## really-lwlib if USE_X_TOOLKIT, else really-oldxmenu.
+## If !HAVE_X11 || USE_GTK, empty.
+## Else if USE_X_TOOLKIT really-lwlib, else really-oldxmenu.
 OLDXMENU_TARGET=@OLDXMENU_TARGET@
 
 ## If !HAVE_X11 || USE_GTK, empty.
 ## Else if USE_X_TOOLKIT, ${lwlibdir}liblw.a.
 ## Else ${oldXMenudir}libXMenu11.a.
+## (Actually, rather than being empty, it is set to "nothing".
+## It is never actually used for anything in this case.
+## This is done because there is a rule with target $(OLDXMENU) below,
+## and I think it might be a syntax error with some makes to have
+## an empty target, even if the associated rule is never run.
+## http://lists.gnu.org/archive/html/help-make/2010-05/msg00058.html
+## The alternative would be to put that rule in a makefile fragment.)
 OLDXMENU=@OLDXMENU@
 
 ## If HAVE_X11 && !USE_GTK, ${OLDXMENU} ../src/${OLDXMENU}; else empty.
@@ -282,16 +291,20 @@
 
 UNEXEC_OBJ = @unexec@
 
+CANNOT_DUMP=@cannot_dump@
+
+DEPDIR=deps
+## -MMD -MF ${DEPDIR}/$*.d if AUTO_DEPEND; else empty.
+DEPFLAGS=@DEPFLAGS@
+## test -d ${DEPDIR} || mkdir ${DEPDIR} (if AUTO_DEPEND); else ':'.
+MKDEPDIR=@MKDEPDIR@
+
 # ========================== start of cpp stuff =======================
 /* From here on, comments must be done in C syntax.  */
 
 #define NOT_C_CODE
 #include "config.h"
 
-#ifdef AUTO_DEPEND
-DEPFLAGS = -MMD -MF deps/$*.d
-#endif
-
 /* If NS_IMPL_GNUSTEP, some definitions and includes are expanded here.  */
 @NS_IMPL_GNUSTEP_INC@
 
@@ -318,63 +331,13 @@
 
 .SUFFIXES: .m
 .c.o:
-#ifdef AUTO_DEPEND
-	@-test -d deps || mkdir deps
-#endif
+	@$(MKDEPDIR)
 	$(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $<
 .m.o:
-#ifdef AUTO_DEPEND
-	@-test -d deps || mkdir deps
-#endif
+	@$(MKDEPDIR)
 	$(CC) -c $(CPPFLAGS) $(ALL_OBJC_CFLAGS) $<
 
 
-/* A macro which other sections of Makefile can redefine to munge the
-   flags before they are passed to LD.  This is helpful if you have
-   redefined LD to something odd, like "gcc".
-   (The YMF prefix is a holdover from the old name "ymakefile".)  */
-#define YMF_PASS_LDFLAGS(flags) flags
-
-
-#ifdef ORDINARY_LINK
-LD = $(CC)
-
-#else /* not ORDINARY_LINK */
-GNULIB_VAR = $(LIB_GCC)
-
-/* Fix linking if compiled with GCC.  */
-#if defined (__GNUC__) && ! defined (LINKER)
-/* Versions of GCC >= 2.0 put their library, libgcc.a, in obscure
-   places that are difficult to figure out at make time.  Fortunately,
-   these same versions allow you to pass arbitrary flags on to the
-   linker, so there is no reason not to use it as a linker.
-
-   Well, it is not quite perfect.  The "-nostdlib" keeps GCC from
-   searching for libraries in its internal directories, so we have to
-   ask GCC explicitly where to find libgcc.a.  */
-#define LINKER $(CC) -nostdlib
-/* GCC passes any argument prefixed with -Xlinker directly to the linker.
-   See prefix-args.c for an explanation of why we do not do this with the
-   shell''s ``for'' construct.  Note that sane people do not have '.' in
-   their paths, so we must use ./prefix-args.  */
-#undef YMF_PASS_LDFLAGS
-#define YMF_PASS_LDFLAGS(flags) `./prefix-args -Xlinker flags`
-#endif /* defined (__GNUC__) && ! defined (LINKER) */
-
-#ifdef LINKER
-LD=LINKER
-#else /* not LINKER */
-LD=ld
-#endif /* not LINKER */
-
-#endif /* not ORDINARY_LINK */
-
-
-#ifdef NS_IMPL_GNUSTEP
-LD=$(CC) -rdynamic
-#endif
-
-
 /* lastfile must follow all files whose initialized data areas should
    be dumped as pure by dump-emacs.  */
 obj=    dispnew.o frame.o scroll.o xdisp.o menu.o $(XMENU_OBJ) window.o \
@@ -634,29 +597,29 @@
 /* Construct full set of libraries to be linked.
    Note that SunOS needs -lm to come before -lc; otherwise, you get
    duplicated symbols.  If the standard libraries were compiled
-   with GCC, we might need gnulib again after them.  */
+   with GCC, we might need LIB_GCC again after them.  */
 
 LIBES = $(LOADLIBES) $(LIBS) $(LIBX_BASE) $(LIBX_OTHER) $(LIBSOUND) \
    $(RSVG_LIBS) $(DBUS_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \
    $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) ${GCONF_LIBS} ${LIBSELINUX_LIBS} \
    $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \
-   $(GNULIB_VAR) $(LIB_MATH) $(LIB_STANDARD) $(GNULIB_VAR)
+   $(LIB_GCC) $(LIB_MATH) $(LIB_STANDARD) $(LIB_GCC)
 
 all: emacs${EXEEXT} $(OTHER_FILES)
 
 /* Does anyone ever pay attention to the load-path-shadows output here?  */
+/* The dumped Emacs is as functional and more efficient than
+   bootstrap-emacs, so we replace the latter with the former.  */
 emacs${EXEEXT}: temacs${EXEEXT} ${etc}DOC ${lisp}
-#ifdef CANNOT_DUMP
-	rm -f emacs${EXEEXT}
-	ln temacs${EXEEXT} emacs${EXEEXT}
-	-EMACSLOADPATH=${lispsource} ./emacs -q -batch -f list-load-path-shadows
-#else
-	LC_ALL=C $(RUN_TEMACS) -batch -l loadup dump
-	@: This new Emacs is as functional and more efficient then
-	@: bootstrap-emacs, so let us replace it.
-	-ln -f emacs${EXEEXT} bootstrap-emacs${EXEEXT}
-	-./emacs -q -batch -f list-load-path-shadows
-#endif /* ! defined (CANNOT_DUMP) */
+	if test "${CANNOT_DUMP}" = "yes"; then \
+	  ln -f temacs${EXEEXT} emacs${EXEEXT}; \
+	  EMACSLOADPATH=${lispsource} ./emacs -q -batch \
+	    -f list-load-path-shadows || true; \
+	else \
+	  LC_ALL=C $(RUN_TEMACS) -batch -l loadup dump || exit 1; \
+	  ln -f emacs${EXEEXT} bootstrap-emacs${EXEEXT}; \
+	  ./emacs -q -batch -f list-load-path-shadows || true; \
+	fi
 
 /* We run make-docfile twice because the command line may get too long
    on some systems.  */
@@ -682,6 +645,8 @@
 buildobj.h: Makefile
 	echo "#define BUILDOBJ \"${obj} ${otherobj} " "\"" > buildobj.h
 
+#define YMF_PASS_LDFLAGS(flags) @YMF_PASS_LDFLAGS@
+
 temacs${EXEEXT}: $(START_FILES) stamp-oldxmenu ${obj} ${otherobj} prefix-args${EXEEXT}
 	$(LD) YMF_PASS_LDFLAGS ( ${TEMACS_LDFLAGS} \
 	  ${NS_IMPL_GNUSTEP_TEMACS_LDFLAGS} ) \
@@ -692,8 +657,9 @@
 	$(CC) $(LDFLAGS) prefix-args.o -o prefix-args
 
 
-/* Only (possibly) used if HAVE_X11 && !USE_GTK, but no harm in always
-   defining.  */
+/* The following oldxmenu-related rules are only (possibly) used if
+   HAVE_X11 && !USE_GTK, but there is no harm in always defining them
+   (provided we take a little care that OLDXMENU is never empty).  */
 really-lwlib:
 	cd ${lwlibdir}; ${MAKE} ${MFLAGS} \
     CC='${CC}' CFLAGS='${CFLAGS}' MAKE='${MAKE}'
@@ -711,13 +677,10 @@
 stamp-oldxmenu: ${OLDXMENU_DEPS}
 	touch stamp-oldxmenu
 
-/* HAVE_X11 implies HAVE_X_WINDOWS and HAVE_MENUS.  */
-#if defined (HAVE_X11) && ! defined (USE_GTK)
 /* Supply an ordering for parallel make.  */
 ../src/$(OLDXMENU): ${OLDXMENU}
 
 $(OLDXMENU): $(OLDXMENU_TARGET)
-#endif /* HAVE_X11 && !USE_GTK */ 
 
 ../config.status:: epaths.in
 	@echo "The file epaths.h needs to be set up from epaths.in."
@@ -730,278 +693,14 @@
 	exit 1
 
 ecrt0.o: ecrt0.c $(config_h)
-#ifdef AUTO_DEPEND
-	@-test -d deps || mkdir deps
-#endif
+	@$(MKDEPDIR)
 	$(CC) -c $(ALL_CFLAGS) ${srcdir}/ecrt0.c
 doc.o: buildobj.h
 
-#ifndef AUTO_DEPEND
-
-/* FIXME some of these dependencies are platform-specific.
-Eg callproc.c only depends on w32.h for WINDOWSNT builds.
-One way to fix this would be to replace w32.h (etc) by $(W32_H),
-a variable set by configure.  Does not seem worth the trouble.
-Since the w32 build does not even use this file, you might ask
-why these dependencies are here at all...
 
-nsgui.h: In fact, every .o file depends directly or indirectly on
-dispextern.h and hence nsgui.h under NS.  But the ones that actually
-use stuff there are more limited.  */
-atimer.o: atimer.c atimer.h syssignal.h systime.h lisp.h blockinput.h \
- $(config_h)
-bidi.o: bidi.c buffer.h character.h dispextern.h lisp.h $(config_h)
-buffer.o: buffer.c buffer.h region-cache.h commands.h window.h \
-   $(INTERVALS_H) blockinput.h atimer.h systime.h character.h \
-   indent.h keyboard.h coding.h keymap.h frame.h lisp.h $(config_h)
-callint.o: callint.c window.h commands.h buffer.h keymap.h \
-   keyboard.h dispextern.h systime.h coding.h composite.h lisp.h $(config_h)
-callproc.o: callproc.c epaths.h buffer.h commands.h lisp.h $(config_h) \
-	process.h systty.h syssignal.h character.h coding.h ccl.h msdos.h \
-        composite.h w32.h blockinput.h atimer.h systime.h frame.h termhooks.h \
-        buffer.h
-casefiddle.o: casefiddle.c syntax.h commands.h buffer.h character.h \
-   composite.h keymap.h lisp.h $(config_h)
-casetab.o: casetab.c buffer.h character.h lisp.h $(config_h)
-category.o: category.c category.h buffer.h charset.h keymap.h	\
-	character.h lisp.h $(config_h)
-ccl.o: ccl.c ccl.h charset.h character.h coding.h composite.h lisp.h $(config_h)
-character.o: character.c character.h buffer.h charset.h composite.h disptab.h \
-   lisp.h $(config_h)
-charset.o: charset.c charset.h character.h buffer.h coding.h composite.h \
-   disptab.h lisp.h $(config_h)
-chartab.o: charset.h character.h ccl.h lisp.h $(config_h)
-coding.o: coding.c coding.h ccl.h buffer.h character.h charset.h composite.h \
-	window.h dispextern.h frame.h termhooks.h lisp.h $(config_h)
-cm.o: cm.c frame.h cm.h termhooks.h termchar.h dispextern.h lisp.h $(config_h)
-cmds.o: cmds.c syntax.h buffer.h character.h commands.h window.h lisp.h $(config_h) \
-	msdos.h dispextern.h keyboard.h keymap.h systime.h coding.h frame.h \
-        composite.h
-pre-crt0.o: pre-crt0.c
-dbusbind.o: dbusbind.c termhooks.h frame.h keyboard.h lisp.h $(config_h)
-dired.o: dired.c commands.h buffer.h lisp.h $(config_h) character.h charset.h \
-   coding.h regex.h systime.h blockinput.h atimer.h composite.h
-dispnew.o: dispnew.c systime.h commands.h process.h frame.h coding.h \
-   window.h buffer.h termchar.h termopts.h termhooks.h cm.h \
-   disptab.h indent.h $(INTERVALS_H) nsgui.h \
-   xterm.h blockinput.h atimer.h character.h msdos.h keyboard.h \
-   syssignal.h lisp.h $(config_h)
-doc.o: doc.c lisp.h $(config_h) epaths.h buffer.h keyboard.h keymap.h \
-   character.h systime.h coding.h composite.h
-doprnt.o: doprnt.c character.h lisp.h $(config_h)
-dosfns.o: buffer.h termchar.h termhooks.h frame.h blockinput.h window.h \
-   msdos.h dosfns.h dispextern.h charset.h coding.h atimer.h systime.h \
-   lisp.h $(config_h)
-editfns.o: editfns.c window.h buffer.h systime.h $(INTERVALS_H) character.h \
-   coding.h frame.h blockinput.h atimer.h lisp.h $(config_h)
-emacs.o: emacs.c commands.h systty.h syssignal.h blockinput.h process.h \
-   termhooks.h buffer.h atimer.h systime.h $(INTERVALS_H) lisp.h $(config_h) \
-   window.h dispextern.h keyboard.h keymap.h frame.h coding.h
-fileio.o: fileio.c window.h buffer.h systime.h $(INTERVALS_H) character.h \
-   coding.h msdos.h blockinput.h atimer.h lisp.h $(config_h) frame.h commands.h
-filelock.o: filelock.c buffer.h character.h coding.h systime.h composite.h \
-   lisp.h $(config_h)
-filemode.o: filemode.c $(config_h)
-frame.o: frame.c xterm.h window.h frame.h termhooks.h commands.h keyboard.h \
-   blockinput.h atimer.h systime.h buffer.h character.h fontset.h font.h    \
-   msdos.h dosfns.h dispextern.h w32term.h nsgui.h termchar.h coding.h \
-   composite.h lisp.h $(config_h) termhooks.h ccl.h
-fringe.o: fringe.c dispextern.h nsgui.h frame.h window.h buffer.h termhooks.h \
-   blockinput.h atimer.h systime.h lisp.h $(config_h)
-font.o: font.c dispextern.h frame.h window.h ccl.h character.h charset.h \
-   font.h lisp.h $(config_h) buffer.h composite.h fontset.h xterm.h nsgui.h
-ftfont.o: dispextern.h frame.h character.h charset.h composite.h font.h \
-   lisp.h $(config_h) blockinput.h atimer.h systime.h coding.h fontset.h \
-   ccl.h ftfont.h
-fontset.o: fontset.c fontset.h ccl.h buffer.h character.h \
-   charset.h frame.h keyboard.h termhooks.h font.h lisp.h $(config_h) \
-   blockinput.h atimer.h systime.h coding.h $(INTERVALS_H) nsgui.h \
-   window.h xterm.h
-getloadavg.o: getloadavg.c $(config_h)
-gtkutil.o: gtkutil.c gtkutil.h xterm.h lisp.h frame.h lisp.h $(config_h) \
-  blockinput.h window.h atimer.h systime.h termhooks.h keyboard.h \
-  charset.h coding.h syssignal.h dispextern.h composite.h
-image.o: image.c frame.h window.h dispextern.h blockinput.h atimer.h \
-   systime.h xterm.h w32term.h w32gui.h font.h epaths.h character.h coding.h \
-   nsterm.h nsgui.h lisp.h $(config_h) composite.h termhooks.h ccl.h
-indent.o: indent.c frame.h window.h indent.h buffer.h lisp.h $(config_h) termchar.h \
-   termopts.h disptab.h region-cache.h character.h category.h \
-   keyboard.h systime.h coding.h $(INTERVALS_H)
-insdel.o: insdel.c window.h buffer.h $(INTERVALS_H) blockinput.h character.h \
-   dispextern.h atimer.h systime.h region-cache.h lisp.h $(config_h)
-keyboard.o: keyboard.c termchar.h termhooks.h termopts.h buffer.h character.h \
-   commands.h frame.h window.h macros.h disptab.h keyboard.h syssignal.h \
-   systime.h syntax.h $(INTERVALS_H) blockinput.h atimer.h composite.h \
-   xterm.h puresize.h msdos.h keymap.h w32term.h nsterm.h nsgui.h coding.h \
-   lisp.h $(config_h)
-keymap.o: keymap.c buffer.h commands.h keyboard.h termhooks.h blockinput.h \
-   atimer.h systime.h puresize.h character.h charset.h $(INTERVALS_H) keymap.h window.h \
-   coding.h frame.h lisp.h $(config_h)
-lastfile.o: lastfile.c $(config_h)
-macros.o: macros.c window.h buffer.h commands.h macros.h keyboard.h \
-	dispextern.h lisp.h $(config_h) systime.h coding.h composite.h
-gmalloc.o: gmalloc.c $(config_h)
-ralloc.o: ralloc.c lisp.h $(config_h)
-vm-limit.o: vm-limit.c mem-limits.h lisp.h $(config_h)
-marker.o: marker.c buffer.h character.h lisp.h $(config_h)
-md5.o: md5.c md5.h $(config_h)
-minibuf.o: minibuf.c syntax.h frame.h window.h keyboard.h systime.h \
-   buffer.h commands.h character.h msdos.h $(INTERVALS_H) keymap.h \
-   termhooks.h lisp.h $(config_h) coding.h
-mktime.o: mktime.c $(config_h)
-msdos.o: msdos.c msdos.h dosfns.h systime.h termhooks.h dispextern.h frame.h \
-   termopts.h termchar.h character.h coding.h ccl.h disptab.h window.h \
-   keyboard.h $(INTERVALS_H) buffer.h commands.h blockinput.h atimer.h lisp.h $(config_h)
-nsfns.o: nsfns.m charset.h nsterm.h nsgui.h frame.h window.h buffer.h \
-  dispextern.h fontset.h $(INTERVALS_H) keyboard.h blockinput.h \
-  atimer.h systime.h epaths.h termhooks.h coding.h systime.h lisp.h $(config_h)
-nsfont.o: nsterm.h dispextern.h frame.h lisp.h lisp.h $(config_h)
-nsimage.o: nsimage.m nsterm.h lisp.h $(config_h)
-nsmenu.o: nsmenu.m termhooks.h frame.h window.h dispextern.h \
-  nsgui.h keyboard.h blockinput.h atimer.h systime.h buffer.h \
-  nsterm.h lisp.h $(config_h)
-nsterm.o: nsterm.m blockinput.h atimer.h systime.h syssignal.h nsterm.h \
-  nsgui.h frame.h charset.h ccl.h dispextern.h fontset.h termhooks.h \
-  termopts.h termchar.h disptab.h buffer.h window.h keyboard.h \
-  $(INTERVALS_H) process.h coding.h lisp.h $(config_h)
-nsselect.o: nsselect.m blockinput.h nsterm.h nsgui.h frame.h lisp.h $(config_h)
-process.o: process.c process.h buffer.h window.h termhooks.h termopts.h \
-   commands.h syssignal.h systime.h systty.h syswait.h frame.h dispextern.h \
-   blockinput.h atimer.h charset.h coding.h ccl.h msdos.h composite.h \
-   keyboard.h lisp.h $(config_h) character.h xgselect.h sysselect.h
-regex.o: regex.c syntax.h buffer.h lisp.h $(config_h) regex.h category.h character.h
-region-cache.o: region-cache.c buffer.h region-cache.h lisp.h $(config_h)
-scroll.o: scroll.c termchar.h dispextern.h frame.h msdos.h keyboard.h \
-   termhooks.h lisp.h $(config_h) systime.h coding.h composite.h window.h
-search.o: search.c regex.h commands.h buffer.h region-cache.h syntax.h \
-   blockinput.h atimer.h systime.h category.h character.h charset.h \
-   $(INTERVALS_H) \
-   lisp.h $(config_h)
-sound.o: sound.c dispextern.h syssignal.h lisp.h $(config_h) atimer.h systime.h
-strftime.o: strftime.c $(config_h)
-syntax.o: syntax.c syntax.h buffer.h commands.h category.h character.h \
-   keymap.h regex.h $(INTERVALS_H) lisp.h $(config_h)
-sysdep.o: sysdep.c syssignal.h systty.h systime.h syswait.h blockinput.h \
-   process.h dispextern.h termhooks.h termchar.h termopts.h coding.h \
-   frame.h atimer.h window.h msdos.h dosfns.h keyboard.h cm.h lisp.h $(config_h) \
-   composite.h
-term.o: term.c termchar.h termhooks.h termopts.h lisp.h $(config_h) cm.h frame.h \
-   disptab.h keyboard.h character.h charset.h coding.h ccl.h xterm.h \
-   msdos.h window.h keymap.h blockinput.h atimer.h systime.h systty.h \
-   syssignal.h $(INTERVALS_H) buffer.h
-termcap.o: termcap.c lisp.h $(config_h)
-terminal.o: terminal.c frame.h termchar.h termhooks.h charset.h coding.h \
-   keyboard.h lisp.h $(config_h) dispextern.h composite.h systime.h
-terminfo.o: terminfo.c lisp.h $(config_h)
-tparam.o: tparam.c lisp.h $(config_h)
-undo.o: undo.c buffer.h commands.h window.h dispextern.h lisp.h $(config_h)
-unexaix.o: unexaix.c lisp.h $(config_h)
-unexalpha.o: unexalpha.c $(config_h)
-unexcw.o: unexcw.c lisp.h $(config_h)
-unexec.o: unexec.c lisp.h $(config_h)
-unexelf.o: unexelf.c $(config_h)
-unexhp9k800.o: unexhp9k800.c $(config_h)
-unexmacosx.o: unexmacosx.c $(config_h)
-unexsol.o: unexsol.c lisp.h $(config_h)
-unexw32.o: unexw32.c $(config_h)
-w16select.o: w16select.c dispextern.h frame.h blockinput.h atimer.h systime.h \
-   msdos.h buffer.h charset.h coding.h composite.h lisp.h $(config_h)
-widget.o: widget.c xterm.h frame.h dispextern.h widgetprv.h \
-   $(srcdir)/../lwlib/lwlib.h lisp.h $(config_h)
-window.o: window.c indent.h commands.h frame.h window.h buffer.h termchar.h \
-   disptab.h keyboard.h msdos.h coding.h termhooks.h \
-   keymap.h blockinput.h atimer.h systime.h $(INTERVALS_H) \
-   xterm.h w32term.h nsterm.h nsgui.h lisp.h $(config_h)
-xdisp.o: xdisp.c macros.h commands.h process.h indent.h buffer.h dispextern.h \
-   coding.h termchar.h frame.h window.h disptab.h termhooks.h character.h \
-   charset.h lisp.h $(config_h) keyboard.h $(INTERVALS_H) region-cache.h \
-   xterm.h w32term.h nsterm.h nsgui.h msdos.h composite.h fontset.h ccl.h \
-   blockinput.h atimer.h systime.h keymap.h font.h
-xfaces.o: xfaces.c dispextern.h frame.h xterm.h buffer.h blockinput.h	\
-   window.h character.h charset.h msdos.h dosfns.h composite.h atimer.h	\
-   systime.h keyboard.h fontset.h w32term.h nsterm.h coding.h ccl.h \
-   $(INTERVALS_H) nsgui.h termchar.h termhooks.h font.h lisp.h $(config_h)
-xfns.o: xfns.c buffer.h frame.h window.h keyboard.h xterm.h dispextern.h \
-   $(srcdir)/../lwlib/lwlib.h blockinput.h atimer.h systime.h epaths.h \
-   character.h charset.h coding.h gtkutil.h lisp.h $(config_h) termhooks.h \
-   fontset.h termchar.h font.h xsettings.h $(INTERVALS_H) ccl.h
-xfont.o: dispextern.h xterm.h frame.h blockinput.h character.h charset.h \
-   font.h lisp.h $(config_h) atimer.h systime.h fontset.h ccl.h
-xftfont.o: dispextern.h xterm.h frame.h blockinput.h character.h charset.h \
-   font.h lisp.h $(config_h) atimer.h systime.h fontset.h ccl.h ftfont.h
-ftxfont.o: dispextern.h xterm.h frame.h blockinput.h character.h charset.h \
-   font.h lisp.h $(config_h) atimer.h systime.h fontset.h ccl.h
-menu.o: menu.c lisp.h keyboard.h keymap.h frame.h termhooks.h blockinput.h \
-   dispextern.h $(srcdir)/../lwlib/lwlib.h xterm.h gtkutil.h menu.h \
-   lisp.h $(config_h) systime.h coding.h composite.h window.h atimer.h nsgui.h
-xmenu.o: xmenu.c xterm.h termhooks.h window.h dispextern.h frame.h buffer.h \
-   charset.h keyboard.h $(srcdir)/../lwlib/lwlib.h blockinput.h atimer.h \
-   systime.h gtkutil.h msdos.h coding.h menu.h lisp.h $(config_h) composite.h \
-   keymap.h sysselect.h
-xterm.o: xterm.c xterm.h termhooks.h termopts.h termchar.h window.h buffer.h \
-   dispextern.h frame.h disptab.h blockinput.h atimer.h systime.h syssignal.h \
-   keyboard.h emacs-icon.h character.h charset.h ccl.h fontset.h composite.h \
-   coding.h process.h gtkutil.h font.h fontset.h lisp.h $(config_h) \
-   xsettings.h intervals.h keymap.h xgselect.h sysselect.h
-xselect.o: xselect.c process.h dispextern.h frame.h xterm.h blockinput.h \
-  buffer.h atimer.h systime.h termhooks.h lisp.h $(config_h) keyboard.h \
-  coding.h composite.h
-xgselect.o: xgselect.h systime.h sysselect.h lisp.h $(config_h)
-xrdb.o: xrdb.c lisp.h $(config_h) epaths.h
-xsmfns.o: xsmfns.c lisp.h $(config_h) systime.h sysselect.h termhooks.h xterm.h \
-  lisp.h termopts.h frame.h dispextern.h
-xsettings.o: xterm.h xsettings.h lisp.h frame.h termhooks.h $(config_h) \
-  dispextern.h keyboard.h systime.h coding.h composite.h blockinput.h atimer.h \
-  termopts.h
+/* If HAVE_NS, some ns-specific rules (for OTHER_FILES) are inserted here.  */
+@ns_frag@
 
-/* The files of Lisp proper.  */
-alloc.o: alloc.c process.h frame.h window.h buffer.h  puresize.h syssignal.h \
- keyboard.h blockinput.h atimer.h systime.h character.h lisp.h $(config_h) \
- $(INTERVALS_H) termhooks.h
-bytecode.o: bytecode.c buffer.h syntax.h character.h window.h dispextern.h \
-  frame.h xterm.h lisp.h $(config_h)
-data.o: data.c buffer.h puresize.h character.h syssignal.h keyboard.h frame.h \
-   termhooks.h systime.h coding.h composite.h dispextern.h font.h ccl.h \
-   lisp.h $(config_h)
-eval.o: eval.c commands.h keyboard.h blockinput.h atimer.h systime.h \
-  dispextern.h lisp.h $(config_h) coding.h composite.h xterm.h
-floatfns.o: floatfns.c syssignal.h lisp.h $(config_h)
-fns.o: fns.c commands.h lisp.h $(config_h) frame.h buffer.h character.h keyboard.h \
- keymap.h window.h dispextern.h $(INTERVALS_H) coding.h md5.h \
- blockinput.h atimer.h systime.h xterm.h
-print.o: print.c process.h frame.h window.h buffer.h keyboard.h character.h \
-   lisp.h $(config_h) termchar.h $(INTERVALS_H) msdos.h termhooks.h \
-   blockinput.h atimer.h systime.h font.h charset.h coding.h ccl.h
-lread.o: lread.c commands.h keyboard.h buffer.h epaths.h character.h \
- charset.h lisp.h $(config_h) $(INTERVALS_H) termhooks.h coding.h msdos.h \
- systime.h frame.h blockinput.h atimer.h
-
-/* Text properties support.  */
-composite.o: composite.c buffer.h character.h coding.h font.h ccl.h \
-	 frame.h termhooks.h $(INTERVALS_H) window.h lisp.h $(config_h)
-intervals.o: intervals.c buffer.h $(INTERVALS_H) keyboard.h puresize.h \
-	keymap.h lisp.h $(config_h) systime.h coding.h
-textprop.o: textprop.c buffer.h window.h $(INTERVALS_H) \
-	lisp.h $(config_h)
-
-#endif /* ! AUTO_DEPEND */
-
-/* System-specific programs to be made.
-   OTHER_FILES select which of these should be compiled.  */
-
-#ifdef HAVE_NS
-${ns_appdir}: ${ns_appsrc}
-	rm -fr ${ns_appdir}
-	mkdir -p ${ns_appdir}
-	( cd ${ns_appsrc} ; tar cfh - . ) | ( cd ${ns_appdir} ; umask 022; tar xf - )
-#endif /* HAVE_NS */
-
-/* These are only used if HAVE_NS, but no harm in always defining them.  */
-${ns_appbindir}Emacs: emacs${EXEEXT}
-	mkdir -p ${ns_appbindir}
-	cp -f emacs${EXEEXT} ${ns_appbindir}Emacs
-
-ns-app: ${ns_appdir} ${ns_appbindir}Emacs
 
 mostlyclean:
 	rm -f temacs${EXEEXT} prefix-args${EXEEXT} core *.core \#* *.o libXMenu11.a liblw.a
@@ -1010,7 +709,7 @@
 	rm -f buildobj.h
 clean: mostlyclean
 	rm -f emacs-*.*.*${EXEEXT} emacs${EXEEXT}
-	-rm -rf deps
+	-rm -rf ${DEPDIR}
 	test "X${ns_appdir}" = "X" || rm -rf ${ns_appdir}
 
 /* bootstrap-clean is used to clean up just before a bootstrap.
@@ -1102,16 +801,14 @@
 
 bootstrap-emacs${EXEEXT}: temacs${EXEEXT}
 	cd ../lisp; $(MAKE) $(MFLAGS) update-subdirs
-#ifdef CANNOT_DUMP
-	ln -f temacs${EXEEXT} bootstrap-emacs${EXEEXT}
-#else
-	$(RUN_TEMACS) --batch --load loadup bootstrap
-	mv -f emacs${EXEEXT} bootstrap-emacs${EXEEXT}
-#endif /* ! defined (CANNOT_DUMP) */
+	if test "${CANNOT_DUMP}" = "yes"; then \
+	  ln -f temacs${EXEEXT} bootstrap-emacs${EXEEXT}; \
+	else \
+	  $(RUN_TEMACS) --batch --load loadup bootstrap || exit 1; \
+	  mv -f emacs${EXEEXT} bootstrap-emacs${EXEEXT}; \
+	fi
 	@: Compile some files earlier to speed up further compilation.
 	cd ../lisp; $(MAKE) $(MFLAGS) compile-first EMACS=${bootstrap_exe}
 
-#ifdef AUTO_DEPEND
-ALLOBJS=$(START_FILES) ${obj} ${otherobj} prefix-args.o
--include $(ALLOBJS:%.o=deps/%.d)
-#endif
+/* Insert either autodeps.mk (if AUTO_DEPEND), else deps.mk.  */
+@deps_frag@
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/autodeps.mk	Tue May 25 09:35:50 2010 +0900
@@ -0,0 +1,6 @@
+/* autodeps.mk --- src/Makefile fragment for GNU Emacs
+
+This is inserted in src/Makefile if AUTO_DEPEND=yes.  */
+
+ALLOBJS=$(START_FILES) ${obj} ${otherobj} prefix-args.o
+-include $(ALLOBJS:%.o=${DEPDIR}/%.d)
--- a/src/bidi.c	Tue May 25 09:32:24 2010 +0900
+++ b/src/bidi.c	Tue May 25 09:35:50 2010 +0900
@@ -543,6 +543,7 @@
 #define BIDI_CACHE_CHUNK 200
 static struct bidi_it *bidi_cache;
 static size_t bidi_cache_size = 0;
+static size_t elsz = sizeof (struct bidi_it);
 static int bidi_cache_idx;	/* next unused cache slot */
 static int bidi_cache_last_idx;	/* slot of last cache hit */
 
@@ -558,8 +559,9 @@
 {
   if (bidi_cache_size > BIDI_CACHE_CHUNK)
     {
-      bidi_cache_size = BIDI_CACHE_CHUNK * sizeof (struct bidi_it);
-      bidi_cache = (struct bidi_it *) xrealloc (bidi_cache, bidi_cache_size);
+      bidi_cache_size = BIDI_CACHE_CHUNK;
+      bidi_cache =
+	(struct bidi_it *) xrealloc (bidi_cache, bidi_cache_size * elsz);
     }
   bidi_cache_reset ();
 }
@@ -688,9 +690,9 @@
       /* Enlarge the cache as needed.  */
       if (idx >= bidi_cache_size)
 	{
-	  bidi_cache_size += BIDI_CACHE_CHUNK * sizeof (struct bidi_it);
+	  bidi_cache_size += BIDI_CACHE_CHUNK;
 	  bidi_cache =
-	    (struct bidi_it *) xrealloc (bidi_cache, bidi_cache_size);
+	    (struct bidi_it *) xrealloc (bidi_cache, bidi_cache_size * elsz);
 	}
       /* Character positions should correspond to cache positions 1:1.
 	 If we are outside the range of cached positions, the cache is
@@ -705,7 +707,6 @@
       bidi_copy_it (&bidi_cache[idx], bidi_it);
       if (!resolved)
 	bidi_cache[idx].resolved_level = -1;
-      bidi_cache[idx].new_paragraph = 0;
     }
   else
     {
--- a/src/config.in	Tue May 25 09:32:24 2010 +0900
+++ b/src/config.in	Tue May 25 09:35:50 2010 +0900
@@ -27,9 +27,6 @@
 #define EMACS_CONFIG_H
 
 
-/* Generate dependencies with gcc. */
-#undef AUTO_DEPEND
-
 /* Define to 1 if the mktime function is broken. */
 #undef BROKEN_MKTIME
 
@@ -841,6 +838,9 @@
 /* Define to 1 if you are using NS windowing under GNUstep. */
 #undef NS_IMPL_GNUSTEP
 
+/* Define if the C compiler is the linker. */
+#undef ORDINARY_LINK
+
 /* Define to the address where bug reports for this package should be sent. */
 #undef PACKAGE_BUGREPORT
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/deps.mk	Tue May 25 09:35:50 2010 +0900
@@ -0,0 +1,279 @@
+/* deps.mk --- src/Makefile fragment for GNU Emacs
+
+Copyright (C) 1985, 1987, 1988, 1993, 1994, 1995, 1999, 2000, 2001, 2002,
+  2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+  Free Software Foundation, Inc.
+
+This file is part of GNU Emacs.
+
+GNU Emacs is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+GNU Emacs is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+Commentary:
+
+This file is inserted in src/Makefile if AUTO_DEPEND=no.
+It defines static dependencies between the various source files.
+
+FIXME some of these dependencies are platform-specific.
+Eg callproc.c only depends on w32.h for WINDOWSNT builds.
+One way to fix this would be to replace w32.h (etc) by $(W32_H),
+a variable set by configure.  Does not seem worth the trouble.
+Since the w32 build does not even use this file, you might ask
+why these dependencies are here at all...
+
+nsgui.h: In fact, every .o file depends directly or indirectly on
+dispextern.h and hence nsgui.h under NS.  But the ones that actually
+use stuff there are more limited.
+
+Code:  */
+
+atimer.o: atimer.c atimer.h syssignal.h systime.h lisp.h blockinput.h \
+ $(config_h)
+bidi.o: bidi.c buffer.h character.h dispextern.h lisp.h $(config_h)
+buffer.o: buffer.c buffer.h region-cache.h commands.h window.h \
+   $(INTERVALS_H) blockinput.h atimer.h systime.h character.h \
+   indent.h keyboard.h coding.h keymap.h frame.h lisp.h $(config_h)
+callint.o: callint.c window.h commands.h buffer.h keymap.h \
+   keyboard.h dispextern.h systime.h coding.h composite.h lisp.h $(config_h)
+callproc.o: callproc.c epaths.h buffer.h commands.h lisp.h $(config_h) \
+   process.h systty.h syssignal.h character.h coding.h ccl.h msdos.h \
+   composite.h w32.h blockinput.h atimer.h systime.h frame.h termhooks.h \
+   buffer.h
+casefiddle.o: casefiddle.c syntax.h commands.h buffer.h character.h \
+   composite.h keymap.h lisp.h $(config_h)
+casetab.o: casetab.c buffer.h character.h lisp.h $(config_h)
+category.o: category.c category.h buffer.h charset.h keymap.h	\
+   character.h lisp.h $(config_h)
+ccl.o: ccl.c ccl.h charset.h character.h coding.h composite.h lisp.h $(config_h)
+character.o: character.c character.h buffer.h charset.h composite.h disptab.h \
+   lisp.h $(config_h)
+charset.o: charset.c charset.h character.h buffer.h coding.h composite.h \
+   disptab.h lisp.h $(config_h)
+chartab.o: charset.h character.h ccl.h lisp.h $(config_h)
+coding.o: coding.c coding.h ccl.h buffer.h character.h charset.h composite.h \
+   window.h dispextern.h frame.h termhooks.h lisp.h $(config_h)
+cm.o: cm.c frame.h cm.h termhooks.h termchar.h dispextern.h lisp.h $(config_h)
+cmds.o: cmds.c syntax.h buffer.h character.h commands.h window.h lisp.h \
+   $(config_h) msdos.h dispextern.h keyboard.h keymap.h systime.h \
+   coding.h frame.h composite.h
+pre-crt0.o: pre-crt0.c
+dbusbind.o: dbusbind.c termhooks.h frame.h keyboard.h lisp.h $(config_h)
+dired.o: dired.c commands.h buffer.h lisp.h $(config_h) character.h charset.h \
+   coding.h regex.h systime.h blockinput.h atimer.h composite.h
+dispnew.o: dispnew.c systime.h commands.h process.h frame.h coding.h \
+   window.h buffer.h termchar.h termopts.h termhooks.h cm.h \
+   disptab.h indent.h $(INTERVALS_H) nsgui.h \
+   xterm.h blockinput.h atimer.h character.h msdos.h keyboard.h \
+   syssignal.h lisp.h $(config_h)
+doc.o: doc.c lisp.h $(config_h) epaths.h buffer.h keyboard.h keymap.h \
+   character.h systime.h coding.h composite.h
+doprnt.o: doprnt.c character.h lisp.h $(config_h)
+dosfns.o: buffer.h termchar.h termhooks.h frame.h blockinput.h window.h \
+   msdos.h dosfns.h dispextern.h charset.h coding.h atimer.h systime.h \
+   lisp.h $(config_h)
+editfns.o: editfns.c window.h buffer.h systime.h $(INTERVALS_H) character.h \
+   coding.h frame.h blockinput.h atimer.h lisp.h $(config_h)
+emacs.o: emacs.c commands.h systty.h syssignal.h blockinput.h process.h \
+   termhooks.h buffer.h atimer.h systime.h $(INTERVALS_H) lisp.h $(config_h) \
+   window.h dispextern.h keyboard.h keymap.h frame.h coding.h
+fileio.o: fileio.c window.h buffer.h systime.h $(INTERVALS_H) character.h \
+   coding.h msdos.h blockinput.h atimer.h lisp.h $(config_h) frame.h commands.h
+filelock.o: filelock.c buffer.h character.h coding.h systime.h composite.h \
+   lisp.h $(config_h)
+filemode.o: filemode.c $(config_h)
+frame.o: frame.c xterm.h window.h frame.h termhooks.h commands.h keyboard.h \
+   blockinput.h atimer.h systime.h buffer.h character.h fontset.h font.h    \
+   msdos.h dosfns.h dispextern.h w32term.h nsgui.h termchar.h coding.h \
+   composite.h lisp.h $(config_h) termhooks.h ccl.h
+fringe.o: fringe.c dispextern.h nsgui.h frame.h window.h buffer.h termhooks.h \
+   blockinput.h atimer.h systime.h lisp.h $(config_h)
+font.o: font.c dispextern.h frame.h window.h ccl.h character.h charset.h \
+   font.h lisp.h $(config_h) buffer.h composite.h fontset.h xterm.h nsgui.h
+ftfont.o: dispextern.h frame.h character.h charset.h composite.h font.h \
+   lisp.h $(config_h) blockinput.h atimer.h systime.h coding.h fontset.h \
+   ccl.h ftfont.h
+fontset.o: fontset.c fontset.h ccl.h buffer.h character.h \
+   charset.h frame.h keyboard.h termhooks.h font.h lisp.h $(config_h) \
+   blockinput.h atimer.h systime.h coding.h $(INTERVALS_H) nsgui.h \
+   window.h xterm.h
+getloadavg.o: getloadavg.c $(config_h)
+gtkutil.o: gtkutil.c gtkutil.h xterm.h lisp.h frame.h lisp.h $(config_h) \
+   blockinput.h window.h atimer.h systime.h termhooks.h keyboard.h \
+   charset.h coding.h syssignal.h dispextern.h composite.h
+image.o: image.c frame.h window.h dispextern.h blockinput.h atimer.h \
+   systime.h xterm.h w32term.h w32gui.h font.h epaths.h character.h coding.h \
+   nsterm.h nsgui.h lisp.h $(config_h) composite.h termhooks.h ccl.h
+indent.o: indent.c frame.h window.h indent.h buffer.h lisp.h $(config_h) \
+   termchar.h termopts.h disptab.h region-cache.h character.h category.h \
+   keyboard.h systime.h coding.h $(INTERVALS_H)
+insdel.o: insdel.c window.h buffer.h $(INTERVALS_H) blockinput.h character.h \
+   dispextern.h atimer.h systime.h region-cache.h lisp.h $(config_h)
+keyboard.o: keyboard.c termchar.h termhooks.h termopts.h buffer.h character.h \
+   commands.h frame.h window.h macros.h disptab.h keyboard.h syssignal.h \
+   systime.h syntax.h $(INTERVALS_H) blockinput.h atimer.h composite.h \
+   xterm.h puresize.h msdos.h keymap.h w32term.h nsterm.h nsgui.h coding.h \
+   lisp.h $(config_h)
+keymap.o: keymap.c buffer.h commands.h keyboard.h termhooks.h blockinput.h \
+   atimer.h systime.h puresize.h character.h charset.h $(INTERVALS_H) \
+   keymap.h window.h coding.h frame.h lisp.h $(config_h)
+lastfile.o: lastfile.c $(config_h)
+macros.o: macros.c window.h buffer.h commands.h macros.h keyboard.h \
+   dispextern.h lisp.h $(config_h) systime.h coding.h composite.h
+gmalloc.o: gmalloc.c $(config_h)
+ralloc.o: ralloc.c lisp.h $(config_h)
+vm-limit.o: vm-limit.c mem-limits.h lisp.h $(config_h)
+marker.o: marker.c buffer.h character.h lisp.h $(config_h)
+md5.o: md5.c md5.h $(config_h)
+minibuf.o: minibuf.c syntax.h frame.h window.h keyboard.h systime.h \
+   buffer.h commands.h character.h msdos.h $(INTERVALS_H) keymap.h \
+   termhooks.h lisp.h $(config_h) coding.h
+mktime.o: mktime.c $(config_h)
+msdos.o: msdos.c msdos.h dosfns.h systime.h termhooks.h dispextern.h frame.h \
+   termopts.h termchar.h character.h coding.h ccl.h disptab.h window.h \
+   keyboard.h $(INTERVALS_H) buffer.h commands.h blockinput.h atimer.h \
+   lisp.h $(config_h)
+nsfns.o: nsfns.m charset.h nsterm.h nsgui.h frame.h window.h buffer.h \
+   dispextern.h fontset.h $(INTERVALS_H) keyboard.h blockinput.h \
+   atimer.h systime.h epaths.h termhooks.h coding.h systime.h lisp.h $(config_h)
+nsfont.o: nsterm.h dispextern.h frame.h lisp.h lisp.h $(config_h)
+nsimage.o: nsimage.m nsterm.h lisp.h $(config_h)
+nsmenu.o: nsmenu.m termhooks.h frame.h window.h dispextern.h \
+   nsgui.h keyboard.h blockinput.h atimer.h systime.h buffer.h \
+   nsterm.h lisp.h $(config_h)
+nsterm.o: nsterm.m blockinput.h atimer.h systime.h syssignal.h nsterm.h \
+   nsgui.h frame.h charset.h ccl.h dispextern.h fontset.h termhooks.h \
+   termopts.h termchar.h disptab.h buffer.h window.h keyboard.h \
+   $(INTERVALS_H) process.h coding.h lisp.h $(config_h)
+nsselect.o: nsselect.m blockinput.h nsterm.h nsgui.h frame.h lisp.h $(config_h)
+process.o: process.c process.h buffer.h window.h termhooks.h termopts.h \
+   commands.h syssignal.h systime.h systty.h syswait.h frame.h dispextern.h \
+   blockinput.h atimer.h charset.h coding.h ccl.h msdos.h composite.h \
+   keyboard.h lisp.h $(config_h) character.h xgselect.h sysselect.h
+regex.o: regex.c syntax.h buffer.h lisp.h $(config_h) regex.h \
+   category.h character.h
+region-cache.o: region-cache.c buffer.h region-cache.h lisp.h $(config_h)
+scroll.o: scroll.c termchar.h dispextern.h frame.h msdos.h keyboard.h \
+   termhooks.h lisp.h $(config_h) systime.h coding.h composite.h window.h
+search.o: search.c regex.h commands.h buffer.h region-cache.h syntax.h \
+   blockinput.h atimer.h systime.h category.h character.h charset.h \
+   $(INTERVALS_H) \
+   lisp.h $(config_h)
+sound.o: sound.c dispextern.h syssignal.h lisp.h $(config_h) atimer.h systime.h
+strftime.o: strftime.c $(config_h)
+syntax.o: syntax.c syntax.h buffer.h commands.h category.h character.h \
+   keymap.h regex.h $(INTERVALS_H) lisp.h $(config_h)
+sysdep.o: sysdep.c syssignal.h systty.h systime.h syswait.h blockinput.h \
+   process.h dispextern.h termhooks.h termchar.h termopts.h coding.h \
+   frame.h atimer.h window.h msdos.h dosfns.h keyboard.h cm.h lisp.h \
+   $(config_h) composite.h
+term.o: term.c termchar.h termhooks.h termopts.h lisp.h $(config_h) \
+   cm.h frame.h disptab.h keyboard.h character.h charset.h coding.h ccl.h \
+   xterm.h msdos.h window.h keymap.h blockinput.h atimer.h systime.h \
+   systty.h syssignal.h $(INTERVALS_H) buffer.h
+termcap.o: termcap.c lisp.h $(config_h)
+terminal.o: terminal.c frame.h termchar.h termhooks.h charset.h coding.h \
+   keyboard.h lisp.h $(config_h) dispextern.h composite.h systime.h
+terminfo.o: terminfo.c lisp.h $(config_h)
+tparam.o: tparam.c lisp.h $(config_h)
+undo.o: undo.c buffer.h commands.h window.h dispextern.h lisp.h $(config_h)
+unexaix.o: unexaix.c lisp.h $(config_h)
+unexalpha.o: unexalpha.c $(config_h)
+unexcw.o: unexcw.c lisp.h $(config_h)
+unexec.o: unexec.c lisp.h $(config_h)
+unexelf.o: unexelf.c $(config_h)
+unexhp9k800.o: unexhp9k800.c $(config_h)
+unexmacosx.o: unexmacosx.c $(config_h)
+unexsol.o: unexsol.c lisp.h $(config_h)
+unexw32.o: unexw32.c $(config_h)
+w16select.o: w16select.c dispextern.h frame.h blockinput.h atimer.h systime.h \
+   msdos.h buffer.h charset.h coding.h composite.h lisp.h $(config_h)
+widget.o: widget.c xterm.h frame.h dispextern.h widgetprv.h \
+   $(srcdir)/../lwlib/lwlib.h lisp.h $(config_h)
+window.o: window.c indent.h commands.h frame.h window.h buffer.h termchar.h \
+   disptab.h keyboard.h msdos.h coding.h termhooks.h \
+   keymap.h blockinput.h atimer.h systime.h $(INTERVALS_H) \
+   xterm.h w32term.h nsterm.h nsgui.h lisp.h $(config_h)
+xdisp.o: xdisp.c macros.h commands.h process.h indent.h buffer.h dispextern.h \
+   coding.h termchar.h frame.h window.h disptab.h termhooks.h character.h \
+   charset.h lisp.h $(config_h) keyboard.h $(INTERVALS_H) region-cache.h \
+   xterm.h w32term.h nsterm.h nsgui.h msdos.h composite.h fontset.h ccl.h \
+   blockinput.h atimer.h systime.h keymap.h font.h
+xfaces.o: xfaces.c dispextern.h frame.h xterm.h buffer.h blockinput.h	\
+   window.h character.h charset.h msdos.h dosfns.h composite.h atimer.h	\
+   systime.h keyboard.h fontset.h w32term.h nsterm.h coding.h ccl.h \
+   $(INTERVALS_H) nsgui.h termchar.h termhooks.h font.h lisp.h $(config_h)
+xfns.o: xfns.c buffer.h frame.h window.h keyboard.h xterm.h dispextern.h \
+   $(srcdir)/../lwlib/lwlib.h blockinput.h atimer.h systime.h epaths.h \
+   character.h charset.h coding.h gtkutil.h lisp.h $(config_h) termhooks.h \
+   fontset.h termchar.h font.h xsettings.h $(INTERVALS_H) ccl.h
+xfont.o: dispextern.h xterm.h frame.h blockinput.h character.h charset.h \
+   font.h lisp.h $(config_h) atimer.h systime.h fontset.h ccl.h
+xftfont.o: dispextern.h xterm.h frame.h blockinput.h character.h charset.h \
+   font.h lisp.h $(config_h) atimer.h systime.h fontset.h ccl.h ftfont.h
+ftxfont.o: dispextern.h xterm.h frame.h blockinput.h character.h charset.h \
+   font.h lisp.h $(config_h) atimer.h systime.h fontset.h ccl.h
+menu.o: menu.c lisp.h keyboard.h keymap.h frame.h termhooks.h blockinput.h \
+   dispextern.h $(srcdir)/../lwlib/lwlib.h xterm.h gtkutil.h menu.h \
+   lisp.h $(config_h) systime.h coding.h composite.h window.h atimer.h nsgui.h
+xmenu.o: xmenu.c xterm.h termhooks.h window.h dispextern.h frame.h buffer.h \
+   charset.h keyboard.h $(srcdir)/../lwlib/lwlib.h blockinput.h atimer.h \
+   systime.h gtkutil.h msdos.h coding.h menu.h lisp.h $(config_h) composite.h \
+   keymap.h sysselect.h
+xterm.o: xterm.c xterm.h termhooks.h termopts.h termchar.h window.h buffer.h \
+   dispextern.h frame.h disptab.h blockinput.h atimer.h systime.h syssignal.h \
+   keyboard.h emacs-icon.h character.h charset.h ccl.h fontset.h composite.h \
+   coding.h process.h gtkutil.h font.h fontset.h lisp.h $(config_h) \
+   xsettings.h intervals.h keymap.h xgselect.h sysselect.h
+xselect.o: xselect.c process.h dispextern.h frame.h xterm.h blockinput.h \
+   buffer.h atimer.h systime.h termhooks.h lisp.h $(config_h) keyboard.h \
+   coding.h composite.h
+xgselect.o: xgselect.h systime.h sysselect.h lisp.h $(config_h)
+xrdb.o: xrdb.c lisp.h $(config_h) epaths.h
+xsmfns.o: xsmfns.c lisp.h $(config_h) systime.h sysselect.h termhooks.h \
+   xterm.h lisp.h termopts.h frame.h dispextern.h
+xsettings.o: xterm.h xsettings.h lisp.h frame.h termhooks.h $(config_h) \
+   dispextern.h keyboard.h systime.h coding.h composite.h blockinput.h \
+   atimer.h termopts.h
+
+/* The files of Lisp proper.  */
+alloc.o: alloc.c process.h frame.h window.h buffer.h  puresize.h syssignal.h \
+   keyboard.h blockinput.h atimer.h systime.h character.h lisp.h $(config_h) \
+   $(INTERVALS_H) termhooks.h
+bytecode.o: bytecode.c buffer.h syntax.h character.h window.h dispextern.h \
+  frame.h xterm.h lisp.h $(config_h)
+data.o: data.c buffer.h puresize.h character.h syssignal.h keyboard.h frame.h \
+   termhooks.h systime.h coding.h composite.h dispextern.h font.h ccl.h \
+   lisp.h $(config_h)
+eval.o: eval.c commands.h keyboard.h blockinput.h atimer.h systime.h \
+   dispextern.h lisp.h $(config_h) coding.h composite.h xterm.h
+floatfns.o: floatfns.c syssignal.h lisp.h $(config_h)
+fns.o: fns.c commands.h lisp.h $(config_h) frame.h buffer.h character.h \
+   keyboard.h keymap.h window.h dispextern.h $(INTERVALS_H) coding.h md5.h \
+   blockinput.h atimer.h systime.h xterm.h
+print.o: print.c process.h frame.h window.h buffer.h keyboard.h character.h \
+   lisp.h $(config_h) termchar.h $(INTERVALS_H) msdos.h termhooks.h \
+   blockinput.h atimer.h systime.h font.h charset.h coding.h ccl.h
+lread.o: lread.c commands.h keyboard.h buffer.h epaths.h character.h \
+   charset.h lisp.h $(config_h) $(INTERVALS_H) termhooks.h coding.h msdos.h \
+   systime.h frame.h blockinput.h atimer.h
+
+/* Text properties support.  */
+composite.o: composite.c buffer.h character.h coding.h font.h ccl.h \
+   frame.h termhooks.h $(INTERVALS_H) window.h lisp.h $(config_h)
+intervals.o: intervals.c buffer.h $(INTERVALS_H) keyboard.h puresize.h \
+   keymap.h lisp.h $(config_h) systime.h coding.h
+textprop.o: textprop.c buffer.h window.h $(INTERVALS_H) \
+   lisp.h $(config_h)
+
+
+/* deps.mk ends here  */
--- a/src/dispextern.h	Tue May 25 09:32:24 2010 +0900
+++ b/src/dispextern.h	Tue May 25 09:35:50 2010 +0900
@@ -748,21 +748,29 @@
 
   /* First position in this row.  This is the text position, including
      overlay position information etc, where the display of this row
-     started, and can thus be less the position of the first glyph
-     (e.g. due to invisible text or horizontal scrolling).  BIDI Note:
-     This is the smallest character position in the row, but not
-     necessarily the character that is the leftmost on the display.  */
+     started, and can thus be less than the position of the first
+     glyph (e.g. due to invisible text or horizontal scrolling).
+     BIDI Note: In R2L rows, that have its reversed_p flag set, this
+     position is at or beyond the right edge of the row.  */
   struct display_pos start;
 
   /* Text position at the end of this row.  This is the position after
      the last glyph on this row.  It can be greater than the last
-     glyph position + 1, due to truncation, invisible text etc.  In an
-     up-to-date display, this should always be equal to the start
-     position of the next row.  BIDI Note: this is the character whose
-     buffer position is the largest, but not necessarily the rightmost
-     one on the display.  */
+     glyph position + 1, due to a newline that ends the line,
+     truncation, invisible text etc.  In an up-to-date display, this
+     should always be equal to the start position of the next row.
+     BIDI Note: In R2L rows, this position is at or beyond the left
+     edge of the row.  */
   struct display_pos end;
 
+  /* The smallest and the largest buffer positions that contributed to
+     glyphs in this row.  Note that due to bidi reordering, these are
+     in general different from the text positions stored in `start'
+     and `end' members above, and also different from the buffer
+     positions recorded in the glyphs displayed the leftmost and
+     rightmost on the screen.  */
+  struct text_pos minpos, maxpos;
+
   /* Non-zero means the overlay arrow bitmap is on this line.
      -1 means use default overlay arrow bitmap, else
      it specifies actual fringe bitmap number.  */
@@ -947,16 +955,16 @@
    displayed by ROW, which is not necessarily the smallest horizontal
    position.  */
 
-#define MATRIX_ROW_START_CHARPOS(ROW) ((ROW)->start.pos.charpos)
-#define MATRIX_ROW_START_BYTEPOS(ROW) ((ROW)->start.pos.bytepos)
+#define MATRIX_ROW_START_CHARPOS(ROW) ((ROW)->minpos.charpos)
+#define MATRIX_ROW_START_BYTEPOS(ROW) ((ROW)->minpos.bytepos)
 
 /* Return the character/ byte position at which ROW ends.  BIDI Note:
    this is the largest character/byte position among characters in
    ROW, i.e. the last logical-order character displayed by ROW, which
    is not necessarily the largest horizontal position.  */
 
-#define MATRIX_ROW_END_CHARPOS(ROW) ((ROW)->end.pos.charpos)
-#define MATRIX_ROW_END_BYTEPOS(ROW) ((ROW)->end.pos.bytepos)
+#define MATRIX_ROW_END_CHARPOS(ROW) ((ROW)->maxpos.charpos)
+#define MATRIX_ROW_END_BYTEPOS(ROW) ((ROW)->maxpos.bytepos)
 
 /* Return the vertical position of ROW in MATRIX.  */
 
@@ -1789,7 +1797,7 @@
   EMACS_INT next_en_pos;	/* position of next EN char for ET */
   EMACS_INT ignore_bn_limit;	/* position until which to ignore BNs */
   bidi_dir_t sor;		/* direction of start-of-run in effect */
-  int scan_dir;			/* direction of text scan */
+  int scan_dir;			/* direction of text scan, 1: forw, -1: back */
   int stack_idx;		/* index of current data on the stack */
   /* Note: Everything from here on is not copied/saved when the bidi
      iterator state is saved, pushed, or popped.  So only put here
@@ -2913,8 +2921,8 @@
 void redisplay_preserve_echo_area P_ ((int));
 int set_cursor_from_row P_ ((struct window *, struct glyph_row *,
 			     struct glyph_matrix *, int, int, int, int));
-void init_iterator P_ ((struct it *, struct window *, int,
-			int, struct glyph_row *, enum face_id));
+void init_iterator P_ ((struct it *, struct window *, EMACS_INT,
+			EMACS_INT, struct glyph_row *, enum face_id));
 void init_iterator_to_row_start P_ ((struct it *, struct window *,
 				     struct glyph_row *));
 int get_next_display_element P_ ((struct it *));
--- a/src/dispnew.c	Tue May 25 09:32:24 2010 +0900
+++ b/src/dispnew.c	Tue May 25 09:35:50 2010 +0900
@@ -1188,6 +1188,10 @@
   MATRIX_ROW_START_BYTEPOS (row) += delta_bytes;
   MATRIX_ROW_END_CHARPOS (row) += delta;
   MATRIX_ROW_END_BYTEPOS (row) += delta_bytes;
+  CHARPOS (row->start.pos) += delta;
+  BYTEPOS (row->start.pos) += delta_bytes;
+  CHARPOS (row->end.pos) += delta;
+  BYTEPOS (row->end.pos) += delta_bytes;
 
   if (!row->enabled_p)
     return;
@@ -1748,13 +1752,19 @@
       /* Check that character and byte positions are in sync.  */
       xassert (MATRIX_ROW_START_BYTEPOS (row)
 	       == CHAR_TO_BYTE (MATRIX_ROW_START_CHARPOS (row)));
+      xassert (BYTEPOS (row->start.pos)
+	       == CHAR_TO_BYTE (CHARPOS (row->start.pos)));
 
       /* CHAR_TO_BYTE aborts when invoked for a position > Z.  We can
 	 have such a position temporarily in case of a minibuffer
 	 displaying something like `[Sole completion]' at its end.  */
       if (MATRIX_ROW_END_CHARPOS (row) < BUF_ZV (current_buffer))
-	xassert (MATRIX_ROW_END_BYTEPOS (row)
-		 == CHAR_TO_BYTE (MATRIX_ROW_END_CHARPOS (row)));
+	{
+	  xassert (MATRIX_ROW_END_BYTEPOS (row)
+		   == CHAR_TO_BYTE (MATRIX_ROW_END_CHARPOS (row)));
+	  xassert (BYTEPOS (row->end.pos)
+		   == CHAR_TO_BYTE (CHARPOS (row->end.pos)));
+	}
 
       /* Check that end position of `row' is equal to start position
 	 of next row.  */
@@ -1764,6 +1774,8 @@
 		   == MATRIX_ROW_START_CHARPOS (next));
 	  xassert (MATRIX_ROW_END_BYTEPOS (row)
 		   == MATRIX_ROW_START_BYTEPOS (next));
+	  xassert (CHARPOS (row->end.pos) == CHARPOS (next->start.pos));
+	  xassert (BYTEPOS (row->end.pos) == BYTEPOS (next->start.pos));
 	}
       row = next;
     }
--- a/src/fileio.c	Tue May 25 09:32:24 2010 +0900
+++ b/src/fileio.c	Tue May 25 09:35:50 2010 +0900
@@ -2194,7 +2194,10 @@
   return Qnil;
 }
 
-DEFUN ("delete-file", Fdelete_file, Sdelete_file, 1, 2, "fDelete file: \nP",
+DEFUN ("delete-file", Fdelete_file, Sdelete_file, 1, 2,
+       "(list (read-file-name \"Delete file: \" nil default-directory \
+                (confirm-nonexistent-file-or-buffer))                 \
+              current-prefix-arg)",
        doc: /* Delete file named FILENAME.  If it is a symlink, remove the symlink.
 If file has multiple names, it continues to exist with the other names.
 
--- a/src/image.c	Tue May 25 09:32:24 2010 +0900
+++ b/src/image.c	Tue May 25 09:35:50 2010 +0900
@@ -1582,29 +1582,56 @@
 {
   struct image_cache *c = FRAME_IMAGE_CACHE (f);
 
-  if (c && (!NILP (filter) || INTEGERP (Vimage_cache_eviction_delay)))
-    {
-      EMACS_TIME t;
-      unsigned long old;
-      int i, nfreed;
-
-      EMACS_GET_TIME (t);
-      old = EMACS_SECS (t) - XFASTINT (Vimage_cache_eviction_delay);
+  if (c)
+    {
+      int i, nfreed = 0;
 
       /* Block input so that we won't be interrupted by a SIGIO
 	 while being in an inconsistent state.  */
       BLOCK_INPUT;
 
-      for (i = nfreed = 0; i < c->used; ++i)
+      if (!NILP (filter))
+	{
+	  /* Filter image cache.  */
+	  for (i = 0; i < c->used; ++i)
+	    {
+	      struct image *img = c->images[i];
+	      if (img && (EQ (Qt, filter)
+			  || !NILP (Fmember (filter, img->dependencies))))
+		{
+		  free_image (f, img);
+		  ++nfreed;
+		}
+	    }
+	}
+      else if (INTEGERP (Vimage_cache_eviction_delay))
 	{
-	  struct image *img = c->images[i];
-	  if (img != NULL
-	      && (NILP (filter) ? img->timestamp < old
-		  : (EQ (Qt, filter)
-		     || !NILP (Fmember (filter, img->dependencies)))))
+	  /* Free cache based on timestamp.  */
+	  EMACS_TIME t;
+	  unsigned long old;
+	  int delay, nimages = 0;
+
+	  for (i = 0; i < c->used; ++i)
+	    if (c->images[i])
+	      nimages++;
+
+	  /* If the number of cached images has grown unusually large,
+	     decrease the cache eviction delay (Bug#6230).  */
+	  delay = XFASTINT (Vimage_cache_eviction_delay);
+	  if (nimages > 40)
+	    delay = max (1, 1600 * delay / (nimages*nimages));
+
+	  EMACS_GET_TIME (t);
+	  old = EMACS_SECS (t) - delay;
+
+	  for (i = 0; i < c->used; ++i)
 	    {
-	      free_image (f, img);
-	      ++nfreed;
+	      struct image *img = c->images[i];
+	      if (img && img->timestamp < old)
+		{
+		  free_image (f, img);
+		  ++nfreed;
+		}
 	    }
 	}
 
@@ -1662,11 +1689,13 @@
 }
 
 
-DEFUN ("image-refresh", Fimage_refresh, Simage_refresh,
+DEFUN ("image-flush", Fimage_flush, Simage_flush,
        1, 2, 0,
-       doc: /* Refresh the image with specification SPEC on frame FRAME.
-If SPEC specifies an image file, the displayed image is updated with
-the current contents of that file.
+       doc: /* Fush the image with specification SPEC on frame FRAME.
+This removes the image from the Emacs image cache.  If SPEC specifies
+an image file, the next redisplay of this image will read from the
+current contents of that file.
+
 FRAME nil or omitted means use the selected frame.
 FRAME t means refresh the image on all frames.  */)
      (spec, frame)
@@ -8499,7 +8528,7 @@
 
   defsubr (&Sinit_image_library);
   defsubr (&Sclear_image_cache);
-  defsubr (&Simage_refresh);
+  defsubr (&Simage_flush);
   defsubr (&Simage_size);
   defsubr (&Simage_mask_p);
   defsubr (&Simage_metadata);
@@ -8520,11 +8549,14 @@
   Vx_bitmap_file_path = decode_env_path ((char *) 0, PATH_BITMAPS);
 
   DEFVAR_LISP ("image-cache-eviction-delay", &Vimage_cache_eviction_delay,
-    doc: /* Time after which cached images are removed from the cache.
-When an image has not been displayed this many seconds, remove it
-from the image cache.  Value must be an integer or nil with nil
-meaning don't clear the cache.  */);
-  Vimage_cache_eviction_delay = make_number (30 * 60);
+    doc: /* Maximum time after which images are removed from the cache.
+When an image has not been displayed this many seconds, Emacs
+automatically removes it from the image cache.  If the cache contains
+a large number of images, the actual eviction time may be shorter.
+The value can also be nil, meaning the cache is never cleared.
+
+The function `clear-image-cache' disregards this variable.  */);
+  Vimage_cache_eviction_delay = make_number (300);
 }
 
 void
--- a/src/keyboard.c	Tue May 25 09:32:24 2010 +0900
+++ b/src/keyboard.c	Tue May 25 09:35:50 2010 +0900
@@ -11985,7 +11985,7 @@
 was a kill command.
 
 `last-command' has a separate binding for each terminal device.
-See Info node `(elisp)Multiple displays'.  */);
+See Info node `(elisp)Multiple Terminals'.  */);
 
   DEFVAR_KBOARD ("real-last-command", Vreal_last_command,
 		 doc: /* Same as `last-command', but never altered by Lisp code.  */);
@@ -12123,8 +12123,8 @@
 This is applied to the characters supplied to input methods, not their
 output.  See also `translation-table-for-input'.
 
-This variable has a separate binding for each terminal.  See Info node
-`(elisp)Multiple displays'.  */);
+This variable has a separate binding for each terminal.
+See Info node `(elisp)Multiple Terminals'.  */);
 
   DEFVAR_BOOL ("cannot-suspend", &cannot_suspend,
 	       doc: /* Non-nil means to always spawn a subshell instead of suspending.
@@ -12215,7 +12215,7 @@
 
 `overriding-terminal-local-map' has a separate binding for each
 terminal device.
-See Info node `(elisp)Multiple displays'.  */);
+See Info node `(elisp)Multiple Terminals'.  */);
 
   DEFVAR_LISP ("overriding-local-map", &Voverriding_local_map,
 	       doc: /* Keymap that overrides all other local keymaps.
@@ -12243,7 +12243,7 @@
 and SYMBOL is its name.
 
 `system-key-alist' has a separate binding for each terminal device.
-See Info node `(elisp)Multiple displays'.  */);
+See Info node `(elisp)Multiple Terminals'.  */);
 
   DEFVAR_KBOARD ("local-function-key-map", Vlocal_function_key_map,
                  doc: /* Keymap that translates key sequences to key sequences during input.
@@ -12269,7 +12269,7 @@
 typing `ESC O P x' would return [f1 x].
 
 `local-function-key-map' has a separate binding for each terminal
-device.  See Info node `(elisp)Multiple displays'.  If you need to
+device.  See Info node `(elisp)Multiple Terminals'.  If you need to
 define a binding on all terminals, change `function-key-map'
 instead.  Initially, `local-function-key-map' is an empty keymap that
 has `function-key-map' as its parent on all terminal devices.  */);
--- a/src/m/ibms390x.h	Tue May 25 09:32:24 2010 +0900
+++ b/src/m/ibms390x.h	Tue May 25 09:35:50 2010 +0900
@@ -62,8 +62,6 @@
 /* On the 64 bit architecture, we can use 60 bits for addresses */
 #define VALBITS         60
 
-#define LINKER $(CC) -nostdlib
-
 /* Define XPNTR to avoid or'ing with DATA_SEG_BITS */
 #define XPNTR(a) XUINT (a)
 
--- a/src/m/macppc.h	Tue May 25 09:32:24 2010 +0900
+++ b/src/m/macppc.h	Tue May 25 09:35:50 2010 +0900
@@ -32,12 +32,6 @@
 #define HAVE_TEXT_START
 #endif
 
-/* NAKAJI Hiroyuki <nakaji@tutrp.tut.ac.jp> says this is needed
-   For MkLinux/LinuxPPC.  */
-#ifdef GNU_LINUX
-#define LINKER $(CC) -nostdlib
-#endif
-
 #ifdef _ARCH_PPC64
 #ifndef _LP64
 #define _LP64
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ns.mk	Tue May 25 09:35:50 2010 +0900
@@ -0,0 +1,39 @@
+/* autodeps.mk --- src/Makefile fragment for GNU Emacs
+
+Copyright (C) 2008, 2009, 2010  Free Software Foundation, Inc.
+
+This file is part of GNU Emacs.
+
+GNU Emacs is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+GNU Emacs is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+Commentary:
+
+This is inserted in src/Makefile if HAVE_NS. 
+
+The only reason this is in a separate file is because $ns_appdir,
+which appears as a target, is empty on non-NS builds.  Some makes
+do not like empty targets, even if they are never used.  */
+
+${ns_appdir}: ${ns_appsrc}
+	rm -fr ${ns_appdir}
+	mkdir -p ${ns_appdir}
+	( cd ${ns_appsrc} ; tar cfh - . ) | ( cd ${ns_appdir} ; umask 022; tar xf - )
+
+${ns_appbindir}Emacs: emacs${EXEEXT}
+	mkdir -p ${ns_appbindir}
+	cp -f emacs${EXEEXT} ${ns_appbindir}Emacs
+
+ns-app: ${ns_appdir} ${ns_appbindir}Emacs
+
+/* ns.mk ends here  */
--- a/src/process.c	Tue May 25 09:32:24 2010 +0900
+++ b/src/process.c	Tue May 25 09:35:50 2010 +0900
@@ -3347,11 +3347,25 @@
   /* :service SERVICE -- string, integer (port number), or t (random port).  */
   service = Fplist_get (contact, QCservice);
 
+  /* :host HOST -- hostname, ip address, or 'local for localhost.  */
+  host = Fplist_get (contact, QChost);
+  if (!NILP (host))
+    {
+      if (EQ (host, Qlocal))
+	host = build_string ("localhost");
+      CHECK_STRING (host);
+    }
+
 #ifdef HAVE_LOCAL_SOCKETS
   if (family == AF_LOCAL)
     {
-      /* Host is not used.  */
-      host = Qnil;
+      if (!NILP (host))
+	{
+	  message (":family local ignores the :host \"%s\" property",
+		   SDATA (host));
+	  contact = Fplist_put (contact, QChost, Qnil);
+	  host = Qnil;
+	}
       CHECK_STRING (service);
       bzero (&address_un, sizeof address_un);
       address_un.sun_family = AF_LOCAL;
@@ -3362,15 +3376,6 @@
     }
 #endif
 
-  /* :host HOST -- hostname, ip address, or 'local for localhost.  */
-  host = Fplist_get (contact, QChost);
-  if (!NILP (host))
-    {
-      if (EQ (host, Qlocal))
-	host = build_string ("localhost");
-      CHECK_STRING (host);
-    }
-
   /* Slow down polling to every ten seconds.
      Some kernels have a bug which causes retrying connect to fail
      after a connect.  Polling can interfere with gethostbyname too.  */
--- a/src/s/aix4-2.h	Tue May 25 09:32:24 2010 +0900
+++ b/src/s/aix4-2.h	Tue May 25 09:35:50 2010 +0900
@@ -61,11 +61,7 @@
 /* The kernel symbol where the load average is found is named avenrun.  */
 #define LDAV_SYMBOL "avenrun"
 
-/* Special itemss needed to make Emacs run on this system.  */
-
-#ifndef __GNUC__
-#define LINKER cc
-#endif
+/* Special items needed to make Emacs run on this system.  */
 
 /* The following definition seems to be needed in AIX version 3.1.6.8.
    It may not have been needed in certain earlier versions.  */
@@ -110,7 +106,5 @@
 
 #define UNEXEC unexaix.o
 
-#define ORDINARY_LINK
-
 /* arch-tag: 38fe75ea-6aef-42bd-8449-bc34d921a562
    (do not change this comment) */
--- a/src/s/cygwin.h	Tue May 25 09:32:24 2010 +0900
+++ b/src/s/cygwin.h	Tue May 25 09:35:50 2010 +0900
@@ -1,7 +1,7 @@
 /* System description header file for Cygwin.
 
 Copyright (C) 1985, 1986, 1992, 1999, 2002, 2003, 2004, 2005, 2006,
-  2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+  2007, 2008, 2009, 2010  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -19,7 +19,7 @@
 along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 /* SYSTEM_TYPE should indicate the kind of system you are using.
- It sets the Lisp variable system-type.  */
+   It sets the Lisp variable system-type.  */
 #define SYSTEM_TYPE "cygwin"
 
 /* Emacs can read input using SIGIO and buffering characters itself,
@@ -94,7 +94,6 @@
 #define PENDING_OUTPUT_COUNT(FILE) ((FILE)->_p - (FILE)->_bf._base)
 #define SYSV_SYSTEM_DIR 1
 #define UNEXEC unexcw.o
-#define LINKER $(CC)
 
 #define HAVE_SOCKETS
 
--- a/src/s/darwin.h	Tue May 25 09:32:24 2010 +0900
+++ b/src/s/darwin.h	Tue May 25 09:35:50 2010 +0900
@@ -147,9 +147,6 @@
 #undef HAVE_POSIX_MEMALIGN
 #endif
 
-/* Link this program just by running cc.  */
-#define ORDINARY_LINK
-
 /* Define the following so emacs symbols will not conflict with those
    in the System framework.  Otherwise -prebind will not work.  */
 
--- a/src/s/gnu.h	Tue May 25 09:32:24 2010 +0900
+++ b/src/s/gnu.h	Tue May 25 09:35:50 2010 +0900
@@ -29,8 +29,7 @@
 
 #define SIGNALS_VIA_CHARACTERS
 
-/* GNU needs its own crt0, and libc defines data_start.  */
-#define ORDINARY_LINK
+/* libc defines data_start.  */
 #define DATA_START ({ extern int data_start; (char *) &data_start; })
 
 /* Some losing code fails to include this and then assumes
--- a/src/s/msdos.h	Tue May 25 09:32:24 2010 +0900
+++ b/src/s/msdos.h	Tue May 25 09:35:50 2010 +0900
@@ -82,8 +82,6 @@
 
 #define _NAIVE_DOS_REGS
 
-#define ORDINARY_LINK
-
 /* command.com does not understand `...` so we define this.  */
 #define SEPCHAR ';'
 
--- a/src/s/netbsd.h	Tue May 25 09:32:24 2010 +0900
+++ b/src/s/netbsd.h	Tue May 25 09:35:50 2010 +0900
@@ -26,12 +26,6 @@
 
 #define PENDING_OUTPUT_COUNT(FILE) ((FILE)->_p - (FILE)->_bf._base)
 
-/* On post 1.3 releases of NetBSD, gcc -nostdlib also clears
-   the library search parth, i.e. it won't search /usr/lib
-   for libc and friends.  Using -nostartfiles instead avoids
-   this problem, and will also work on earlier NetBSD releases.  */
-#define LINKER $(CC) -nostartfiles
-
 #define DEFAULT_SOUND_DEVICE "/dev/audio"
 
 /* Greg A. Woods <woods@weird.com> says we must include signal.h
--- a/src/s/usg5-4.h	Tue May 25 09:32:24 2010 +0900
+++ b/src/s/usg5-4.h	Tue May 25 09:35:50 2010 +0900
@@ -69,8 +69,6 @@
 /* On USG systems signal handlers return void.  */
 #define SIGTYPE void
 
-#define ORDINARY_LINK
-
 /* Undump with ELF.  */
 #undef COFF
 
--- a/src/w32.c	Tue May 25 09:32:24 2010 +0900
+++ b/src/w32.c	Tue May 25 09:35:50 2010 +0900
@@ -5700,7 +5700,34 @@
     }
   else
 #endif
-    nchars = _write (fd, buffer, count);
+    {
+      /* Some networked filesystems don't like too large writes, so
+	 break them into smaller chunks.  See the Comments section of
+	 the MSDN documentation of WriteFile for details behind the
+	 choice of the value of CHUNK below.  See also the thread
+	 http://thread.gmane.org/gmane.comp.version-control.git/145294
+	 in the git mailing list.  */
+      const unsigned char *p = buffer;
+      const unsigned chunk = 30 * 1024 * 1024;
+
+      nchars = 0;
+      while (count > 0)
+	{
+	  unsigned this_chunk = count < chunk ? count : chunk;
+	  int n = _write (fd, p, this_chunk);
+
+	  nchars += n;
+	  if (n < 0)
+	    {
+	      nchars = n;
+	      break;
+	    }
+	  else if (n < this_chunk)
+	    break;
+	  count -= n;
+	  p += n;
+	}
+    }
 
   return nchars;
 }
--- a/src/xdisp.c	Tue May 25 09:32:24 2010 +0900
+++ b/src/xdisp.c	Tue May 25 09:35:50 2010 +0900
@@ -2598,7 +2598,7 @@
 init_iterator (it, w, charpos, bytepos, row, base_face_id)
      struct it *it;
      struct window *w;
-     int charpos, bytepos;
+     EMACS_INT charpos, bytepos;
      struct glyph_row *row;
      enum face_id base_face_id;
 {
@@ -3012,7 +3012,7 @@
      struct window *w;
      struct display_pos *pos;
 {
-  int charpos = CHARPOS (pos->pos), bytepos = BYTEPOS (pos->pos);
+  EMACS_INT charpos = CHARPOS (pos->pos), bytepos = BYTEPOS (pos->pos);
   int i, overlay_strings_with_newlines = 0;
 
   /* If POS specifies a position in a display vector, this might
@@ -12486,22 +12486,25 @@
   if (windows_or_buffers_changed && !pause)
     goto retry;
 
-  /* Clear the face cache eventually.  */
-  if (consider_all_windows_p)
-    {
-      if (clear_face_cache_count > CLEAR_FACE_CACHE_COUNT)
-	{
-	  clear_face_cache (0);
-	  clear_face_cache_count = 0;
-	}
-#ifdef HAVE_WINDOW_SYSTEM
-      if (clear_image_cache_count > CLEAR_IMAGE_CACHE_COUNT)
-	{
-	  clear_image_caches (Qnil);
-	  clear_image_cache_count = 0;
-	}
+  /* Clear the face and image caches.
+
+     We used to do this only if consider_all_windows_p.  But the cache
+     needs to be cleared if a timer creates images in the current
+     buffer (e.g. the test case in Bug#6230).  */
+
+  if (clear_face_cache_count > CLEAR_FACE_CACHE_COUNT)
+    {
+      clear_face_cache (0);
+      clear_face_cache_count = 0;
+    }
+
+#ifdef HAVE_WINDOW_SYSTEM
+  if (clear_image_cache_count > CLEAR_IMAGE_CACHE_COUNT)
+    {
+      clear_image_caches (Qnil);
+      clear_image_cache_count = 0;
+    }
 #endif /* HAVE_WINDOW_SYSTEM */
-    }
 
  end_of_redisplay:
   unbind_to (count, Qnil);
@@ -14959,7 +14962,7 @@
   /* The variable new_start now holds the new window start.  The old
      start `start' can be determined from the current matrix.  */
   SET_TEXT_POS_FROM_MARKER (new_start, w->start);
-  start = start_row->start.pos;
+  start = start_row->minpos;
   start_vpos = MATRIX_ROW_VPOS (start_row, w->current_matrix);
 
   /* Clear the desired matrix for the display below.  */
@@ -14998,7 +15001,7 @@
 	    {
 	      /* Advance to the next row as the "start".  */
 	      start_row++;
-	      start = start_row->start.pos;
+	      start = start_row->minpos;
 	      /* If there are no more rows to try, or just one, give up.  */
 	      if (start_row == MATRIX_MODE_LINE_ROW (w->current_matrix) - 1
 		  || w->vscroll || MATRIX_ROW_PARTIALLY_VISIBLE_P (w, start_row)
@@ -15280,39 +15283,26 @@
 	    {
 	      struct glyph *glyph = row->glyphs[TEXT_AREA] + w->cursor.hpos;
 	      struct glyph *end = glyph + row->used[TEXT_AREA];
-	      struct glyph *orig_glyph = glyph;
-	      struct cursor_pos orig_cursor = w->cursor;
-
-	      for (; glyph < end
-		     && (!BUFFERP (glyph->object)
-			 || glyph->charpos != PT);
-		   glyph++)
-		{
-		  w->cursor.hpos++;
-		  w->cursor.x += glyph->pixel_width;
-		}
-	      /* With bidi reordering, charpos changes non-linearly
-		 with hpos, so the right glyph could be to the
-		 left.  */
-	      if (!NILP (XBUFFER (w->buffer)->bidi_display_reordering)
-		  && (!BUFFERP (glyph->object) || glyph->charpos != PT))
-		{
-		  struct glyph *start_glyph = row->glyphs[TEXT_AREA];
-
-		  glyph = orig_glyph - 1;
-		  orig_cursor.hpos--;
-		  orig_cursor.x -= glyph->pixel_width;
-		  for (; glyph >= start_glyph
-			 && (!BUFFERP (glyph->object)
-			     || glyph->charpos != PT);
-		       glyph--)
-		    {
-		      w->cursor.hpos--;
-		      w->cursor.x -= glyph->pixel_width;
-		    }
-		  if (BUFFERP (glyph->object) && glyph->charpos == PT)
-		    w->cursor = orig_cursor;
-		}
+
+	      /* Can't use this optimization with bidi-reordered glyph
+		 rows, unless cursor is already at point. */
+	      if (!NILP (XBUFFER (w->buffer)->bidi_display_reordering))
+		{
+		  if (!(w->cursor.hpos >= 0
+			&& w->cursor.hpos < row->used[TEXT_AREA]
+			&& BUFFERP (glyph->object)
+			&& glyph->charpos == PT))
+		    return 0;
+		}
+	      else
+		for (; glyph < end
+		       && (!BUFFERP (glyph->object)
+			   || glyph->charpos < PT);
+		     glyph++)
+		  {
+		    w->cursor.hpos++;
+		    w->cursor.x += glyph->pixel_width;
+		  }
 	    }
 	}
 
@@ -15892,13 +15882,13 @@
 	 as is, without changing glyph positions since no text has
 	 been added/removed in front of the window end.  */
       r0 = MATRIX_FIRST_TEXT_ROW (current_matrix);
-      if (TEXT_POS_EQUAL_P (start, r0->start.pos)
+      if (TEXT_POS_EQUAL_P (start, r0->minpos)
 	  /* PT must not be in a partially visible line.  */
 	  && !(PT >= MATRIX_ROW_START_CHARPOS (row)
 	       && MATRIX_ROW_BOTTOM_Y (row) > window_text_bottom_y (w)))
 	{
 	  /* We have to compute the window end anew since text
-	     can have been added/removed after it.  */
+	     could have been added/removed after it.  */
 	  w->window_end_pos
 	    = make_number (Z - MATRIX_ROW_END_CHARPOS (row));
 	  w->window_end_bytepos
@@ -15930,7 +15920,7 @@
      start is not in changed text, otherwise positions would not be
      comparable.  */
   row = MATRIX_FIRST_TEXT_ROW (current_matrix);
-  if (!TEXT_POS_EQUAL_P (start, row->start.pos))
+  if (!TEXT_POS_EQUAL_P (start, row->minpos))
     GIVE_UP (16);
 
   /* Give up if the window ends in strings.  Overlay strings
@@ -17322,7 +17312,7 @@
 {
   int cursor_row_p = 1;
 
-  if (PT == MATRIX_ROW_END_CHARPOS (row))
+  if (PT == CHARPOS (row->end.pos))
     {
       /* Suppose the row ends on a string.
 	 Unless the row is continued, that means it ends on a newline
@@ -17359,14 +17349,15 @@
 	{
 	  /* If the row ends in middle of a real character,
 	     and the line is continued, we want the cursor here.
-	     That's because MATRIX_ROW_END_CHARPOS would equal
+	     That's because CHARPOS (ROW->end.pos) would equal
 	     PT if PT is before the character.  */
 	  if (!row->ends_in_ellipsis_p)
 	    cursor_row_p = row->continued_p;
 	  else
 	  /* If the row ends in an ellipsis, then
-	     MATRIX_ROW_END_CHARPOS will equal point after the invisible text.
-	     We want that position to be displayed after the ellipsis.  */
+	     CHARPOS (ROW->end.pos) will equal point after the
+	     invisible text.  We want that position to be displayed
+	     after the ellipsis.  */
 	    cursor_row_p = 0;
 	}
       /* If the row ends at ZV, display the cursor at the end of that
@@ -17502,122 +17493,87 @@
     glyph[-n] = *glyph;
 }
 
-/* Find the positions in a bidi-reordered ROW to serve as ROW->start
-   and ROW->end.  */
-static struct display_pos
-find_row_end (it, row)
+/* Find the positions in a bidi-reordered ROW to serve as ROW->minpos
+   and ROW->maxpos.  */
+static void
+find_row_edges (it, row, min_pos, min_bpos, max_pos, max_bpos)
      struct it *it;
      struct glyph_row *row;
+     EMACS_INT min_pos, min_bpos, max_pos, max_bpos;
 {
   /* FIXME: Revisit this when glyph ``spilling'' in continuation
      lines' rows is implemented for bidi-reordered rows.  */
-  EMACS_INT min_pos = ZV + 1, max_pos = 0;
-  struct glyph *g;
-  struct it save_it;
-  struct text_pos tpos;
-  struct display_pos row_end = it->current;
-
-  for (g = row->glyphs[TEXT_AREA];
-       g < row->glyphs[TEXT_AREA] + row->used[TEXT_AREA];
-       g++)
-    {
-      if (BUFFERP (g->object))
-	{
-	  if (g->charpos > 0 && g->charpos < min_pos)
-	    min_pos = g->charpos;
-	  if (g->charpos > max_pos)
-	    max_pos = g->charpos;
-	}
-    }
-  /* Empty lines have a valid buffer position at their first
-     glyph, but that glyph's OBJECT is zero, as if it didn't come
-     from a buffer.  If we didn't find any valid buffer positions
-     in this row, maybe we have such an empty line.  */
-  if (max_pos == 0 && row->used[TEXT_AREA])
-    {
-      for (g = row->glyphs[TEXT_AREA];
-	   g < row->glyphs[TEXT_AREA] + row->used[TEXT_AREA];
-	   g++)
-	{
-	  if (INTEGERP (g->object))
-	    {
-	      if (g->charpos > 0 && g->charpos < min_pos)
-		min_pos = g->charpos;
-	      if (g->charpos > max_pos)
-		max_pos = g->charpos;
-	    }
-	}
-    }
-
-  /* ROW->start is the value of min_pos, the minimal buffer position
+
+  /* ROW->minpos is the value of min_pos, the minimal buffer position
      we have in ROW.  */
   if (min_pos <= ZV)
-    {
-      /* Avoid calling the costly CHAR_TO_BYTE if possible.  */
-      if (min_pos != row->start.pos.charpos)
-	SET_TEXT_POS (row->start.pos, min_pos, CHAR_TO_BYTE (min_pos));
-      if (max_pos == 0)
-	max_pos = min_pos;
-    }
-
-  /* For ROW->end, we need the position that is _after_ max_pos, in
-     the logical order, unless we are at ZV.  */
+    SET_TEXT_POS (row->minpos, min_pos, min_bpos);
+  else
+    {
+      /* We didn't find _any_ valid buffer positions in any of the
+	 glyphs, so we must trust the iterator's computed
+	 positions.  */
+      row->minpos = row->start.pos;
+      max_pos = CHARPOS (it->current.pos);
+      max_bpos = BYTEPOS (it->current.pos);
+    }
+
+  if (!max_pos)
+    abort ();
+
+  /* Here are the various use-cases for ending the row, and the
+     corresponding values for ROW->maxpos:
+
+     Line ends in a newline from buffer       eol_pos + 1
+     Line is continued from buffer            max_pos + 1
+     Line is truncated on right               it->current.pos
+     Line ends in a newline from string       max_pos
+     Line is continued from string            max_pos
+     Line is continued from display vector    max_pos
+     Line is entirely from a string           min_pos == max_pos
+     Line is entirely from a display vector   min_pos == max_pos
+     Line that ends at ZV                     ZV
+
+     If you discover other use-cases, please add them here as
+     appropriate.  */
   if (row->ends_at_zv_p)
-    {
-      if (!row->used[TEXT_AREA])
-	row->start.pos = row_end.pos;
-    }
-  else if (row->used[TEXT_AREA] && max_pos)
-    {
-      int at_eol_p;
-
-      SET_TEXT_POS (tpos, max_pos, CHAR_TO_BYTE (max_pos));
-      save_it = *it;
-      it->bidi_p = 0;
-      reseat (it, tpos, 0);
-      if (!get_next_display_element (it))
-	abort ();	/* this row cannot be at ZV, see above */
-      at_eol_p = ITERATOR_AT_END_OF_LINE_P (it);
-      set_iterator_to_next (it, 1);
-      row_end = it->current;
-      /* If the character at max_pos is not a newline and the
-	 characters at max_pos+1 is a newline, skip that newline as
-	 well.  Note that this may skip some invisible text.  */
-      if (!at_eol_p
-	  && get_next_display_element (it)
-	  && ITERATOR_AT_END_OF_LINE_P (it))
-	{
-	  set_iterator_to_next (it, 1);
-	  /* Record the position after the newline of a continued row.
-	     We will need that to set ROW->end of the last row
-	     produced for a continued line.  */
-	  if (row->continued_p)
-	    save_it.eol_pos = it->current.pos;
-	  else
-	    {
-	      row_end = it->current;
-	      save_it.eol_pos.charpos = save_it.eol_pos.bytepos = 0;
-	    }
-	}
-      else if (!row->continued_p
-	       && MATRIX_ROW_CONTINUATION_LINE_P (row)
-	       && it->eol_pos.charpos > 0)
-	{
-	  /* Last row of a continued line.  Use the position recorded
-	     in IT->eol_pos, to the effect that the newline belongs to
-	     this row, not to the row which displays the character
-	     with the largest buffer position before the newline.  */
-	  row_end.pos = it->eol_pos;
-	  it->eol_pos.charpos = it->eol_pos.bytepos = 0;
-	}
-      *it = save_it;
-      /* The members of ROW->end that are not taken from buffer
-	 positions are copied from IT->current.  */
-      row_end.string_pos = it->current.string_pos;
-      row_end.overlay_string_index = it->current.overlay_string_index;
-      row_end.dpvec_index = it->current.dpvec_index;
-    }
-  return row_end;
+    row->maxpos = it->current.pos;
+  else if (row->used[TEXT_AREA])
+    {
+      if (row->ends_in_newline_from_string_p)
+	SET_TEXT_POS (row->maxpos, max_pos, max_bpos);
+      else if (CHARPOS (it->eol_pos) > 0)
+	SET_TEXT_POS (row->maxpos,
+		      CHARPOS (it->eol_pos) + 1, BYTEPOS (it->eol_pos) + 1);
+      else if (row->continued_p)
+	{
+	  /* If max_pos is different from IT's current position, it
+	     means IT->method does not belong to the display element
+	     at max_pos.  However, it also means that the display
+	     element at max_pos was displayed in its entirety on this
+	     line, which is equivalent to saying that the next line
+	     starts at the next buffer position.  */
+	  if (IT_CHARPOS (*it) == max_pos && it->method != GET_FROM_BUFFER)
+	    SET_TEXT_POS (row->maxpos, max_pos, max_bpos);
+	  else
+	    {
+	      INC_BOTH (max_pos, max_bpos);
+	      SET_TEXT_POS (row->maxpos, max_pos, max_bpos);
+	    }
+	}
+      else if (row->truncated_on_right_p)
+	/* display_line already called reseat_at_next_visible_line_start,
+	   which puts the iterator at the beginning of the next line, in
+	   the logical order. */
+	row->maxpos = it->current.pos;
+      else if (max_pos == min_pos && it->method != GET_FROM_BUFFER)
+	/* A line that is entirely from a string/image/stretch...  */
+	row->maxpos = row->minpos;
+      else
+	abort ();
+    }
+  else
+    row->maxpos = it->current.pos;
 }
 
 /* Construct the glyph row IT->glyph_row in the desired matrix of
@@ -17637,7 +17593,10 @@
   int wrap_row_used = -1, wrap_row_ascent, wrap_row_height;
   int wrap_row_phys_ascent, wrap_row_phys_height;
   int wrap_row_extra_line_spacing;
+  EMACS_INT wrap_row_min_pos, wrap_row_min_bpos;
+  EMACS_INT wrap_row_max_pos, wrap_row_max_bpos;
   int cvpos;
+  EMACS_INT min_pos = ZV + 1, min_bpos, max_pos = 0, max_bpos;
 
   /* We always start displaying at hpos zero even if hscrolled.  */
   xassert (it->hpos == 0 && it->current_x == 0);
@@ -17694,6 +17653,23 @@
   row->phys_height = it->max_phys_ascent + it->max_phys_descent;
   row->extra_line_spacing = it->max_extra_line_spacing;
 
+/* Utility macro to record max and min buffer positions seen until now.  */
+#define RECORD_MAX_MIN_POS(IT)					\
+  do								\
+    {								\
+      if (IT_CHARPOS (*(IT)) < min_pos)				\
+	{							\
+	  min_pos = IT_CHARPOS (*(IT));				\
+	  min_bpos = IT_BYTEPOS (*(IT));			\
+	}							\
+      if (IT_CHARPOS (*(IT)) > max_pos)				\
+	{							\
+	  max_pos = IT_CHARPOS (*(IT));				\
+	  max_bpos = IT_BYTEPOS (*(IT));			\
+	}							\
+    }								\
+  while (0)
+
   /* Loop generating characters.  The loop is left with IT on the next
      character to display.  */
   while (1)
@@ -17728,7 +17704,8 @@
 	  row->ends_at_zv_p = 1;
 	  /* A row that displays right-to-left text must always have
 	     its last face extended all the way to the end of line,
-	     even if this row ends in ZV.  */
+	     even if this row ends in ZV, because we still write to th
+	     screen left to right.  */
 	  if (row->reversed_p)
 	    extend_face_to_end_of_line (it);
 	  break;
@@ -17762,6 +17739,10 @@
 		  wrap_row_phys_ascent = row->phys_ascent;
 		  wrap_row_phys_height = row->phys_height;
 		  wrap_row_extra_line_spacing = row->extra_line_spacing;
+		  wrap_row_min_pos = min_pos;
+		  wrap_row_min_bpos = min_bpos;
+		  wrap_row_max_pos = max_pos;
+		  wrap_row_max_bpos = max_bpos;
 		  may_wrap = 0;
 		}
 	    }
@@ -17812,6 +17793,10 @@
 					 it->max_extra_line_spacing);
 	  if (it->current_x - it->pixel_width < it->first_visible_x)
 	    row->x = x - it->first_visible_x;
+	  /* Record the maximum and minimum buffer positions seen so
+	     far in glyphs that will be displayed by this row.  */
+	  if (it->bidi_p)
+	    RECORD_MAX_MIN_POS (it);
 	}
       else
 	{
@@ -17845,6 +17830,11 @@
 		      it->current_x = new_x;
 		      it->continuation_lines_width += new_x;
 		      ++it->hpos;
+		      /* Record the maximum and minimum buffer
+			 positions seen so far in glyphs that will be
+			 displayed by this row.  */
+		      if (it->bidi_p)
+			RECORD_MAX_MIN_POS (it);
 		      if (i == nglyphs - 1)
 			{
 			  /* If line-wrap is on, check if a previous
@@ -17919,6 +17909,10 @@
 		      row->phys_ascent = wrap_row_phys_ascent;
 		      row->phys_height = wrap_row_phys_height;
 		      row->extra_line_spacing = wrap_row_extra_line_spacing;
+		      min_pos = wrap_row_min_pos;
+		      min_bpos = wrap_row_min_bpos;
+		      max_pos = wrap_row_max_pos;
+		      max_bpos = wrap_row_max_bpos;
 		      row->continued_p = 1;
 		      row->ends_at_zv_p = 0;
 		      row->exact_window_width_line_p = 0;
@@ -17981,6 +17975,12 @@
 		  /* Increment number of glyphs actually displayed.  */
 		  ++it->hpos;
 
+		  /* Record the maximum and minimum buffer positions
+		     seen so far in glyphs that will be displayed by
+		     this row.  */
+		  if (it->bidi_p)
+		    RECORD_MAX_MIN_POS (it);
+
 		  if (x < it->first_visible_x)
 		    /* Glyph is partially visible, i.e. row starts at
 		       negative X position.  */
@@ -18032,6 +18032,10 @@
 	  if (used_before == 0)
 	    row->glyphs[TEXT_AREA]->charpos = CHARPOS (it->position);
 
+	  /* Record the position of the newline, for use in
+	     find_row_edges.  */
+	  it->eol_pos = it->current.pos;
+
 	  /* Consume the line end.  This skips over invisible lines.  */
 	  set_iterator_to_next (it, 1);
 	  it->continuation_lines_width = 0;
@@ -18111,7 +18115,7 @@
   /* If line is not empty and hscrolled, maybe insert truncation glyphs
      at the left window margin.  */
   if (it->first_visible_x
-      && IT_CHARPOS (*it) != MATRIX_ROW_START_CHARPOS (row))
+      && IT_CHARPOS (*it) != CHARPOS (row->start.pos))
     {
       if (!FRAME_WINDOW_P (it->f))
 	insert_left_trunc_glyphs (it);
@@ -18165,12 +18169,19 @@
 
   /* Remember the position at which this line ends.  */
   row->end = it->current;
-  /* ROW->start and ROW->end must be the smallest and the largest
-     buffer positions in ROW.  But if ROW was bidi-reordered, these
-     two positions can be anywhere in the row, so we must rescan all
-     of the ROW's glyphs to find them.  */
-  if (it->bidi_p)
-    row->end = find_row_end (it, row);
+  if (!it->bidi_p)
+    {
+      row->minpos = row->start.pos;
+      row->maxpos = row->end.pos;
+    }
+  else
+    {
+      /* ROW->minpos and ROW->maxpos must be the smallest and
+	 `1 + the largest' buffer positions in ROW.  But if ROW was
+	 bidi-reordered, these two positions can be anywhere in the
+	 row, so we must determine them now.  */
+      find_row_edges (it, row, min_pos, min_bpos, max_pos, max_bpos);
+    }
 
   /* Record whether this row ends inside an ellipsis.  */
   row->ends_in_ellipsis_p
@@ -18216,6 +18227,7 @@
      row to be used.  */
   it->current_x = it->hpos = 0;
   it->current_y += row->height;
+  SET_TEXT_POS (it->eol_pos, 0, 0);
   ++it->vpos;
   ++it->glyph_row;
   /* The next row should by default use the same value of the
@@ -18226,6 +18238,8 @@
     it->glyph_row->reversed_p = row->reversed_p;
   it->start = row->end;
   return row->displays_text_p;
+
+#undef RECORD_MAX_MIN_POS
 }
 
 DEFUN ("current-bidi-paragraph-direction", Fcurrent_bidi_paragraph_direction,