changeset 110123:6252a1df1110

merge emacs-23
author Kenichi Handa <handa@m17n.org>
date Fri, 27 Aug 2010 23:06:02 +0900
parents 66a2fac996a4 (current diff) 156bbb7866f9 (diff)
children 9e82fd2cdf71
files
diffstat 77 files changed, 3114 insertions(+), 1721 deletions(-) [+]
line wrap: on
line diff
--- a/.bzrignore	Fri Aug 27 23:05:43 2010 +0900
+++ b/.bzrignore	Fri Aug 27 23:06:02 2010 +0900
@@ -68,3 +68,5 @@
 src/core
 core
 lib-src/stamp-*
++*
+lisp/vc
--- a/doc/emacs/ChangeLog	Fri Aug 27 23:05:43 2010 +0900
+++ b/doc/emacs/ChangeLog	Fri Aug 27 23:06:02 2010 +0900
@@ -1,3 +1,7 @@
+2010-08-21  Glenn Morris  <rgm@gnu.org>
+
+	* misc.texi (Amusements): Mention bubbles and animate.
+
 2010-06-23  Glenn Morris  <rgm@gnu.org>
 
 	* abbrevs.texi, basic.texi, buffers.texi, building.texi, calendar.texi:
--- a/doc/emacs/misc.texi	Fri Aug 27 23:05:43 2010 +0900
+++ b/doc/emacs/misc.texi	Fri Aug 27 23:06:02 2010 +0900
@@ -2784,6 +2784,10 @@
   If you want a little more personal involvement, try @kbd{M-x gomoku},
 which plays the game Go Moku with you.
 
+@findex bubbles
+  @kbd{M-x bubbles} is a game in which the object is to remove as many
+bubbles as you can in the smallest number of moves.
+
 @findex blackbox
 @findex mpuz
 @findex 5x5
@@ -2832,6 +2836,11 @@
 @kbd{M-x solitaire} plays a game of solitaire in which you jump pegs
 across other pegs.
 
+@findex animate-birthday-present
+@cindex animate
+The @code{animate} package makes text dance.  For an example, try
+@kbd{M-x animate-birthday-present}.
+
 @findex studlify-region
 @cindex StudlyCaps
 @kbd{M-x studlify-region} studlify-cases the region, producing
--- a/doc/lispref/ChangeLog	Fri Aug 27 23:05:43 2010 +0900
+++ b/doc/lispref/ChangeLog	Fri Aug 27 23:06:02 2010 +0900
@@ -1,3 +1,25 @@
+2010-08-22  Chong Yidong  <cyd@stupidchicken.com>
+
+	* modes.texi (Defining Minor Modes): Doc fix (Bug#6880).
+
+2010-08-19  Chong Yidong  <cyd@stupidchicken.com>
+
+	* objects.texi (Bool-Vector Type): Minor definition tweak (Bug#6878).
+
+2010-08-02  Christoph  <cschol2112@googlemail.com>
+
+	* control.texi (Handling Errors) <error-message-string>: Fix arg name.
+
+2010-07-29  Juanma Barranquero  <lekktu@gmail.com>
+
+	* modes.texi (Defining Minor Modes): Use C-backspace, not C-delete.
+	Suggested by Štěpán Němec <stepnem@gmail.com>.
+
+2010-07-28  Juanma Barranquero  <lekktu@gmail.com>
+
+	* minibuf.texi (High-Level Completion): Document args of
+	`read-buffer-function' (bug#5625).
+
 2010-07-27  Juanma Barranquero  <lekktu@gmail.com>
 
 	* modes.texi (Defining Minor Modes): Use C-delete in examples,
--- a/doc/lispref/control.texi	Fri Aug 27 23:05:43 2010 +0900
+++ b/doc/lispref/control.texi	Fri Aug 27 23:06:02 2010 +0900
@@ -1039,7 +1039,7 @@
 @xref{Definition of signal}.
 @end defspec
 
-@defun error-message-string error-description
+@defun error-message-string error-descriptor
 This function returns the error message string for a given error
 descriptor.  It is useful if you want to handle an error by printing the
 usual error message for that error.  @xref{Definition of signal}.
--- a/doc/lispref/minibuf.texi	Fri Aug 27 23:05:43 2010 +0900
+++ b/doc/lispref/minibuf.texi	Fri Aug 27 23:06:02 2010 +0900
@@ -1222,10 +1222,11 @@
 @end defun
 
 @defopt read-buffer-function
-This variable specifies how to read buffer names.  For example, if you
-set this variable to @code{iswitchb-read-buffer}, all Emacs commands
-that call @code{read-buffer} to read a buffer name will actually use the
-@code{iswitchb} package to read it.
+This variable specifies how to read buffer names.  The function is
+called with the arguments passed to @code{read-buffer}.  For example,
+if you set this variable to @code{iswitchb-read-buffer}, all Emacs
+commands that call @code{read-buffer} to read a buffer name will
+actually use the @code{iswitchb} package to read it.
 @end defopt
 
 @defopt read-buffer-completion-ignore-case
--- a/doc/lispref/modes.texi	Fri Aug 27 23:05:43 2010 +0900
+++ b/doc/lispref/modes.texi	Fri Aug 27 23:06:02 2010 +0900
@@ -1411,14 +1411,20 @@
 when the mode is enabled; if it is @code{nil}, the mode is not displayed
 in the mode line.
 
-The optional argument @var{keymap} specifies the keymap for the minor mode.
-It can be a variable name, whose value is the keymap, or it can be an alist
-specifying bindings in this form:
+The optional argument @var{keymap} specifies the keymap for the minor
+mode.  If non-@code{nil}, it should be a variable name (whose value is
+a keymap), a keymap, or an alist of the form
 
 @example
 (@var{key-sequence} . @var{definition})
 @end example
 
+@noindent
+where each @var{key-sequence} and @var{definition} are arguments
+suitable for passing to @code{define-key} (@pxref{Changing Key
+Bindings}).  If @var{keymap} is a keymap or an alist, this also
+defines the variable @code{@var{mode}-map}.
+
 The above three arguments @var{init-value}, @var{lighter}, and
 @var{keymap} can be (partially) omitted when @var{keyword-args} are
 used.  The @var{keyword-args} consist of keywords followed by
@@ -1494,7 +1500,7 @@
  ;; The indicator for the mode line.
  " Hungry"
  ;; The minor mode bindings.
- '(([C-delete] . hungry-electric-delete))
+ '(([C-backspace] . hungry-electric-delete))
  :group 'hunger)
 @end smallexample
 
@@ -1526,8 +1532,8 @@
  :lighter " Hungry"
  ;; The minor mode bindings.
  :keymap
- '(([C-delete] . hungry-electric-delete)
-   ([C-M-delete]
+ '(([C-backspace] . hungry-electric-delete)
+   ([C-M-backspace]
     . (lambda ()
         (interactive)
         (hungry-electric-delete t))))
--- a/doc/lispref/objects.texi	Fri Aug 27 23:05:43 2010 +0900
+++ b/doc/lispref/objects.texi	Fri Aug 27 23:06:02 2010 +0900
@@ -1189,8 +1189,8 @@
 @node Bool-Vector Type
 @subsection Bool-Vector Type
 
-  A @dfn{bool-vector} is a one-dimensional array of elements that
-must be @code{t} or @code{nil}.
+  A @dfn{bool-vector} is a one-dimensional array whose elements must
+be @code{t} or @code{nil}.
 
   The printed representation of a bool-vector is like a string, except
 that it begins with @samp{#&} followed by the length.  The string
--- a/doc/man/ChangeLog	Fri Aug 27 23:05:43 2010 +0900
+++ b/doc/man/ChangeLog	Fri Aug 27 23:06:02 2010 +0900
@@ -1,3 +1,7 @@
+2010-08-26  Sven Joachim  <svenjoac@gmx.de>
+
+	* emacs.1: Mention "maximized" value for the "fullscreen" X resource.
+
 2010-05-07  Chong Yidong  <cyd@stupidchicken.com>
 
 	* Version 23.2 released.
--- a/doc/man/emacs.1	Fri Aug 27 23:05:43 2010 +0900
+++ b/doc/man/emacs.1	Fri Aug 27 23:06:02 2010 +0900
@@ -403,11 +403,12 @@
 The desired fullscreen size.
 The value can be one of
 .IR fullboth ,
+.IR maximized ,
 .IR fullwidth ,
 or
 .IR fullheight ,
-which correspond to the command-line options `\-fs', `\-fw', and
-`\-fh', respectively.
+which correspond to the command-line options `\-fs', `-mm', `\-fw',
+and `\-fh', respectively.
 Note that this applies to the initial frame only.
 .TP
 .BR geometry " (class " Geometry )
--- a/doc/misc/ChangeLog	Fri Aug 27 23:05:43 2010 +0900
+++ b/doc/misc/ChangeLog	Fri Aug 27 23:06:02 2010 +0900
@@ -1,3 +1,26 @@
+2010-08-26  Michael Albinus  <michael.albinus@gmx.de>
+
+	Sync with Tramp 2.1.19.
+
+	* tramp.texi (Inline methods, Default Method): Mention
+	`tramp-inline-compress-start-size'.  Remove "kludgy" phrase.  Remove
+	remark about doubled "-t" argument.
+	(Auto-save and Backup): Remove reference to Emacs 21.
+	(Filename Syntax): Describe port numbers.
+	(Frequently Asked Questions): Adapt supported (X)Emacs versions.  Adapt
+	supported MS Windows versions.  Remove obsolete URL.  Recommend "sshx"
+	and "scpx" for echoing shells.  Use the $() syntax, texi2dvi reports
+	errors with the backquotes.
+	(External packages): File attributes cache flushing for asynchronous
+	processes.
+	(Traces and Profiles): Describe verbose level 9.
+
+	* trampver.texi: Update release number.
+
+2010-08-01  Juanma Barranquero  <lekktu@gmail.com>
+
+	* org.texi (Footnotes, Tables in HTML export): Fix typos.
+
 2010-07-23  Chong Yidong  <cyd@stupidchicken.com>
 
 	* nxml-mode.texi (Limitations): Remove obsolete discussion (Bug#6708).
--- a/doc/misc/org.texi	Fri Aug 27 23:05:43 2010 +0900
+++ b/doc/misc/org.texi	Fri Aug 27 23:06:02 2010 +0900
@@ -1437,7 +1437,7 @@
 @table @code
 @item [1]
 A plain numeric footnote marker.  Compatible with @file{footnote.el}, but not
-recommended because somthing like @samp{[1]} could easily be part of a code
+recommended because something like @samp{[1]} could easily be part of a code
 snippet.
 @item [fn:name]
 A named footnote reference, where @code{name} is a unique label word, or, for
@@ -9165,7 +9165,7 @@
 Org-mode tables are exported to HTML using the table tag defined in
 @code{org-export-html-table-tag}.  The default setting makes tables without
 cell borders and frame.  If you would like to change this for individual
-tables, place somthing like the following before the table:
+tables, place something like the following before the table:
 
 @cindex #+CAPTION
 @cindex #+ATTR_HTML
Binary file doc/misc/tramp.texi has changed
--- a/doc/misc/trampver.texi	Fri Aug 27 23:05:43 2010 +0900
+++ b/doc/misc/trampver.texi	Fri Aug 27 23:06:02 2010 +0900
@@ -2,14 +2,14 @@
 @c texi/trampver.texi.  Generated from trampver.texi.in by configure.
 
 @c This is part of the Emacs manual.
-@c Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-@c   Free Software Foundation, Inc.
+@c Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009,
+@c   2010 Free Software Foundation, Inc.
 @c See file doclicense.texi for copying conditions.
 
 @c In the Tramp CVS, the version number is auto-frobbed from
 @c configure.ac, so you should edit that file and run
 @c "autoconf && ./configure" to change the version number.
-@set trampver 2.1.18-23.2
+@set trampver 2.1.19
 
 @c Other flags from configuration
 @set instprefix /usr/local
--- a/etc/ChangeLog	Fri Aug 27 23:05:43 2010 +0900
+++ b/etc/ChangeLog	Fri Aug 27 23:06:02 2010 +0900
@@ -1,3 +1,11 @@
+2010-08-22  Alex Harsanyi <harsanyi@mac.com>
+
+	* emacs3.py: Import imp module and use it (Bug#5756).
+
+2010-07-27  Ken Brown  <kbrown@cornell.edu>
+
+	* PROBLEMS: Mention problem with Cygwin 1.5.19.
+
 2010-06-19  Ken Brown  <kbrown@cornell.edu>
 
 	* PROBLEMS: Update Cygwin GCC information.  (Bug#6458)
--- a/etc/PROBLEMS	Fri Aug 27 23:05:43 2010 +0900
+++ b/etc/PROBLEMS	Fri Aug 27 23:06:02 2010 +0900
@@ -2482,6 +2482,14 @@
 As of Emacs 22.1, there have been stability problems with Cygwin
 builds of Emacs using GCC 3.  Cygwin users are advised to use GCC 4.
 
+*** Building Emacs 23.3 and later will fail under Cygwin 1.5.19
+
+This is a consequence of a change to src/dired.c on 2010-07-27.  The
+issue is that Cygwin 1.5.19 did not have d_ino in 'struct dirent'.
+See
+
+  http://lists.gnu.org/archive/html/emacs-devel/2010-07/msg01266.html
+
 *** Building the native MS-Windows port fails due to unresolved externals
 
 The linker error messages look like this:
--- a/etc/emacs3.py	Fri Aug 27 23:05:43 2010 +0900
+++ b/etc/emacs3.py	Fri Aug 27 23:06:02 2010 +0900
@@ -1,10 +1,3 @@
-"""
-Warning: This file is automatically generated from emacs2.py with the
-2to3 script.  Do not hand edit.
-"""
-
-"""Definitions used by commands sent to inferior Python in python.el."""
-
 # Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
 # Author: Dave Love <fx@gnu.org>
 
@@ -23,7 +16,7 @@
 # You should have received a copy of the GNU General Public License
 # along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
-import os, sys, traceback, inspect, __main__
+import os, sys, traceback, inspect, imp, __main__
 
 try:
     set
@@ -216,7 +209,7 @@
     try:
         try:
             if mod in __dict__ and inspect.ismodule (__dict__[mod]):
-                reload (__dict__[mod])
+                imp.reload (__dict__[mod])
             else:
                 __dict__[mod] = __import__ (mod)
         except:
--- a/leim/ChangeLog	Fri Aug 27 23:05:43 2010 +0900
+++ b/leim/ChangeLog	Fri Aug 27 23:06:02 2010 +0900
@@ -1,3 +1,26 @@
+2010-08-15  Andreas Schwab  <schwab@linux-m68k.org>
+
+	* quail/vntelex.el ("vietnamese-telex"): Doc fix.
+
+	* quail/georgian.el: Remove extra backslashes.
+
+2010-08-14  Andreas Schwab  <schwab@linux-m68k.org>
+
+	* quail/arabic.el: Quote [ and ].
+	* quail/latin-ltx.el: Likewise.
+
+	* quail/greek.el ("greek", "greek-postfix"): Change string to
+	character.
+
+2010-08-13  Kenichi Handa  <handa@m17n.org>
+
+	* quail/greek.el ("greek-postfix"): Add rules for Greek style
+	quotes.
+
+2010-08-09  Kenichi Handa  <handa@m17n.org>
+
+	* quail/greek.el ("greek"): Add rules for Greek style quotes.
+
 2010-05-07  Chong Yidong  <cyd@stupidchicken.com>
 
 	* Version 23.2 released.
--- a/leim/quail/arabic.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/leim/quail/arabic.el	Fri Aug 27 23:06:02 2010 +0900
@@ -57,8 +57,8 @@
 
  ("A" ?ِ)
  ("S" ?ٍ)
- ("D" ?])
- ("F" ?[)
+ ("D" ?\])
+ ("F" ?\[)
  ("G" ["لأ"])
  ("H" ?أ)
  ("J" ?ـ)
--- a/leim/quail/georgian.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/leim/quail/georgian.el	Fri Aug 27 23:06:02 2010 +0900
@@ -51,7 +51,7 @@
  ("n" ?ნ)
  ("o" ?ო)
  (".p" ?პ)
- ("\+z"	?ჟ)
+ ("+z" ?ჟ)
  ("r" ?რ)
  ("s" ?ს)
  (".t" ?ტ)
@@ -60,14 +60,14 @@
  ("k" ?ქ)
  (".g" ?ღ)
  ("q" ?ყ)
- ("\+s"	?შ)
- ("\+c"	?ჩ)
+ ("+s" ?შ)
+ ("+c" ?ჩ)
  ("c" ?ც)
  ("j" ?ძ)
  (".c" ?წ)
- (".\+c" ?ჭ)
+ (".+c" ?ჭ)
  ("x" ?ხ)
- ("\+j"	?ჯ)
+ ("+j" ?ჯ)
  ("h" ?ჰ)
  ("q1" ?ჴ)
  ("e0" ?ჱ)
--- a/leim/quail/greek.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/leim/quail/greek.el	Fri Aug 27 23:06:02 2010 +0900
@@ -1279,7 +1279,9 @@
  (";:i" ?,F@(B)
  (":;i" ?,F@(B)
  (";:y" ?,F`(B)
- (":;y" ?,F`(B))
+ (":;y" ?,F`(B)
+ (";<" ?$(Q)((B)
+ (";>" ?$(Q)2(B))
 
 (quail-define-package
  "greek-postfix" "GreekPost" ",FX(B" nil
@@ -1419,7 +1421,12 @@
  ("i:;" ?,F@(B)
  ("i;:" ?,F@(B)
  ("y:;" ?,F`(B)
- ("y;:" ?,F`(B))
+ ("y;:" ?,F`(B)
+ ;; These two are asymmetric with ";<" and ";>" in "greek" input
+ ;; method.  But, as the other Latin postfix methods adopt "<<" and
+ ;; ">>", it may be better to follow them.
+ ("<<" ?$(Q)((B)
+ (">>" ?$(Q)2(B))
 
 
 ;; arch-tag: 2a37e042-db1b-4ecf-b755-117775a3c150
--- a/leim/quail/latin-ltx.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/leim/quail/latin-ltx.el	Fri Aug 27 23:06:02 2010 +0900
@@ -653,7 +653,7 @@
  ("\\lambda" ?λ)
  ("\\langle" ?〈)
  ("\\lbrace" ?{)
- ("\\lbrack" ?[)
+ ("\\lbrack" ?\[)
  ("\\lceil" ?⌈)
  ("\\ldots" ?…)
  ("\\le" ?≤)
@@ -788,7 +788,7 @@
  ("\\quad" ? )
  ("\\rangle" ?〉)
  ("\\rbrace" ?})
- ("\\rbrack" ?])
+ ("\\rbrack" ?\])
  ("\\rceil" ?⌉)
  ("\\rfloor" ?⌋)
  ("\\rightarrow" ?→)
--- a/leim/quail/vntelex.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/leim/quail/vntelex.el	Fri Aug 27 23:06:02 2010 +0900
@@ -53,7 +53,7 @@
   acute         s      as -> ,1a(B
   grave         f      af -> ,1`(B
   hook above    r      ar -> ,1d(B
-  tilde         x      ax  -> ,1c(B
+  tilde         x      ax -> ,1c(B
   dot below     j      aj -> ,1U(B
 
   d bar                dd -> ,1p(B
--- a/lisp/ChangeLog	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/ChangeLog	Fri Aug 27 23:06:02 2010 +0900
@@ -1,3 +1,451 @@
+2010-08-26  Michael Albinus  <michael.albinus@gmx.de>
+
+	Sync with Tramp 2.1.19.
+
+	* net/tramp-cmds.el (tramp-cleanup-all-connections)
+	(tramp-reporter-dump-variable, tramp-load-report-modules)
+	(tramp-append-tramp-buffers): Use `tramp-compat-funcall'.
+	(tramp-bug): Recommend setting of `tramp-verbose' to 9.
+
+	* net/tramp-compat.el (top): Do not autoload
+	`tramp-handle-file-remote-p'.  Load tramp-util.el and tramp-vc.el
+	only when `start-file-process' is not bound.
+	(byte-compile-not-obsolete-vars): Define if not bound.
+	(tramp-compat-funcall): New defmacro.
+	(tramp-compat-line-beginning-position)
+	(tramp-compat-line-end-position)
+	(tramp-compat-temporary-file-directory)
+	(tramp-compat-make-temp-file, tramp-compat-file-attributes)
+	(tramp-compat-copy-file, tramp-compat-copy-directory)
+	(tramp-compat-delete-file, tramp-compat-delete-directory)
+	(tramp-compat-number-sequence, tramp-compat-process-running-p):
+	Use it.
+	(tramp-advice-file-expand-wildcards): Do not use
+	`tramp-handle-file-remote-p'.
+	(tramp-compat-make-temp-file): Simplify fallback implementation.
+	(tramp-compat-copy-file): Add PRESERVE-SELINUX-CONTEXT.
+	(tramp-compat-copy-tree): Remove function.
+	(tramp-compat-delete-file): New defun.
+	(tramp-compat-delete-directory): Provide implementation for older
+	Emacsen.
+	(tramp-compat-file-attributes): Handle only
+	`wrong-number-of-arguments' error.
+
+	* net/tramp-fish.el (tramp-fish-handle-copy-file): Add
+	PRESERVE_SELINUX_CONTEXT.
+	(tramp-fish-handle-delete-file): Add TRASH arg.
+	(tramp-fish-handle-directory-files-and-attributes):
+	Do not use `tramp-fish-handle-file-attributes.
+	(tramp-fish-handle-file-local-copy)
+	(tramp-fish-handle-insert-file-contents)
+	(tramp-fish-maybe-open-connection): Use `with-progress-reporter'.
+
+	* net/tramp-gvfs.el (top): Require url-util.
+	(tramp-gvfs-mount-point): Remove.
+	(tramp-gvfs-file-name-handler-alist): Add `file-selinux-context'
+	and `set-file-selinux-context'.
+	(tramp-gvfs-stringify-dbus-message, tramp-gvfs-send-command)
+	(tramp-gvfs-handle-file-selinux-context)
+	(tramp-gvfs-handle-set-file-selinux-context): New defuns.
+	(with-tramp-dbus-call-method): Format trace message.
+	(tramp-gvfs-handle-copy-file): Handle PRESERVE-SELINUX-CONTEXT.
+	(tramp-gvfs-handle-copy-file, tramp-gvfs-handle-rename-file):
+	Implement backup call, when operation on local files fails.  Use
+	progress reporter.  Flush properties of changed files.
+	(tramp-gvfs-handle-delete-file): Add TRASH arg.  Use
+	`tramp-compat-delete-file'.
+	(tramp-gvfs-handle-expand-file-name): Expand "~/".
+	(tramp-gvfs-handle-make-directory): Make more traces.
+	(tramp-gvfs-handle-write-region): Protect deleting tmpfile.
+	(tramp-gvfs-url-file-name): Hexify file name in url.
+	(tramp-gvfs-fuse-file-name): Take also prefix (like dav shares)
+	into account for the resulting file name.
+	(tramp-gvfs-handler-askquestion): Preserve current message, in
+	order to let progress reporter continue afterwards.  (Bug#6257)
+	Return dummy mountpoint, when the answer is "no".  See
+	`tramp-gvfs-maybe-open-connection'.
+	(tramp-gvfs-handler-mounted-unmounted)
+	(tramp-gvfs-connection-mounted-p): Test also for new mountspec
+	attribute "default_location".  Set "prefix" property.  Handle
+	default-location.
+	(tramp-gvfs-mount-spec): Return both prefix and mountspec.
+	(tramp-gvfs-maybe-open-connection): Test, whether mountpoint
+	exists.  Raise an error, if not (due to a corresponding answer
+	"no" in interactive questions, for example). Use
+	`tramp-compat-funcall'.
+
+	* net/tramp-imap.el (top): Autoload `epg-make-context'.
+	(tramp-imap-handle-copy-file): Add PRESERVE-SELINUX-CONTEXT.
+	(tramp-imap-do-copy-or-rename-file)
+	(tramp-imap-handle-insert-file-contents)
+	(tramp-imap-handle-file-local-copy): Use `with-progress-reporter'.
+	(tramp-imap-handle-delete-file): Add TRASH arg.
+
+	* net/tramp-smb.el (tramp-smb-handle-copy-file): Add
+	PRESERVE-SELINUX-CONTEXT.
+	(tramp-smb-handle-copy-file)
+	(tramp-smb-handle-file-local-copy, tramp-smb-handle-rename-file)
+	(tramp-smb-handle-write-region, tramp-smb-maybe-open-connection):
+	Use `with-progress-reporter'.
+	(tramp-smb-handle-delete-file): Add TRASH arg.
+
+	* net/tramp.el (tramp-methods): Move hostname to the end in all
+	ssh `tramp-login-args'.  Add `tramp-async-args' attribute where
+	appropriate.
+	(tramp-verbose): Describe verbose level 9.
+	(tramp-completion-function-alist)
+	(tramp-file-name-regexp, tramp-chunksize)
+	(tramp-local-coding-commands, tramp-remote-coding-commands)
+	(with-connection-property, tramp-completion-mode-p)
+	(tramp-action-process-alive, tramp-action-out-of-band)
+	(tramp-check-for-regexp, tramp-file-name-p, tramp-equal-remote)
+	(tramp-exists-file-name-handler): Fix docstring.
+	(tramp-remote-process-environment): Use `format' instead of
+	`concat'.  Protect version string by apostroph.
+	(tramp-shell-prompt-pattern): Do not use a shy group in case of
+	XEmacs.
+	(tramp-file-name-regexp-unified)
+	(tramp-completion-file-name-regexp-unified): On W32 systems, do
+	not regard the volume letter as remote filename.  (Bug#5447)
+	(tramp-perl-file-attributes)
+	(tramp-perl-directory-files-and-attributes): Don't pass "$3".
+	(tramp-vc-registered-read-file-names): Read input as
+	here-document, otherwise the command could exceed maximum length
+	of command line.
+	(tramp-file-name-handler-alist): Add `file-selinux-context' and
+	`set-file-selinux-context'.
+	(tramp-debug-message): Add `tramp-compat-funcall' to ignored
+	backtrace functions.
+	(tramp-error-with-buffer): Don't show the connection buffer when
+	we are in completion mode.
+	(tramp-progress-reporter-update, tramp-remote-selinux-p)
+	(tramp-handle-file-selinux-context)
+	(tramp-handle-set-file-selinux-context, tramp-process-sentinel)
+	(tramp-connectable-p, tramp-open-shell, tramp-get-remote-trash):
+	New defuns.
+	(with-progress-reporter): New defmacro.
+	(tramp-debug-outline-regexp): New defconst.
+	(top, tramp-rfn-eshadow-setup-minibuffer)
+	(tramp-rfn-eshadow-update-overlay, tramp-handle-set-file-times)
+	(tramp-handle-dired-compress-file, tramp-handle-shell-command)
+	(tramp-completion-mode-p, tramp-check-for-regexp)
+	(tramp-open-connection-setup-interactive-shell)
+	(tramp-compute-multi-hops, tramp-read-passwd, tramp-clear-passwd)
+	(tramp-time-diff, tramp-coding-system-change-eol-conversion)
+	(tramp-set-process-query-on-exit-flag, tramp-unload-tramp):
+	Use `tramp-compat-funcall'.
+	(tramp-handle-make-symbolic-link): Flush file properties.
+	(tramp-handle-load, tramp-handle-file-local-copy)
+	(tramp-handle-insert-file-contents, tramp-handle-write-region)
+	(tramp-handle-vc-registered, tramp-maybe-send-script)
+	(tramp-find-shell): Use `with-progress-reporter'.
+	(tramp-do-file-attributes-with-stat): Add space in format string,
+	in order to work around a bug in pdksh.  Reported by Gilles Pion
+	<gpion@lfdj.com>.
+	(tramp-handle-verify-visited-file-modtime): Do not send a command
+	when the connection is not established.
+	(tramp-handle-set-file-times): Simplify the check for utc.
+	(tramp-handle-directory-files-and-attributes)
+	(tramp-get-remote-path): Use `copy-tree'.
+	(tramp-completion-handle-file-name-all-completions): Ensure, that
+	non remote files are still checked.  Oops.
+	(tramp-handle-copy-file, tramp-do-copy-or-rename-file): Handle
+	PRESERVE-SELINUX-CONTEXT.
+	(tramp-do-copy-or-rename-file): Add progress reporter.
+	(tramp-do-copy-or-rename-file-directly): Do not use
+	`tramp-handle-file-remote-p'.
+	(tramp-do-copy-or-rename-file-out-of-band):
+	Use `tramp-compat-delete-directory'.
+	(tramp-do-copy-or-rename-file-out-of-band)
+	(tramp-compute-multi-hops, tramp-maybe-open-connection):
+	Use `format-spec-make'.
+	(tramp-handle-delete-file): Add TRASH arg.
+	(tramp-handle-dired-uncache): Flush directory cache, not only file
+	cache.
+	(tramp-handle-expand-file-name)
+	(tramp-completion-handle-file-name-all-completions)
+	(tramp-completion-handle-file-name-completion): Use
+	`tramp-connectable-p'.
+	(tramp-handle-start-file-process): Set connection property "vec".
+	Use it, in order to invalidate file caches.  Check only for
+	`remote-tty' process property.
+	Implement tty setting.  (Bug#4604, Bug#6360)
+	(tramp-file-name-for-operation): Add `call-process-region' and
+	`set-file-selinux-context'.
+	(tramp-find-foreign-file-name-handler)
+	(tramp-advice-make-auto-save-file-name)
+	(tramp-set-auto-save-file-modes): Remove superfluous check for
+	`stringp'.  This is done inside `tramp-tramp-file-p'.
+	(tramp-file-name-handler): Trace 'quit.  Catch the error for some
+	operations when we are in completion mode.  This gives the user
+	the chance to correct the file name in the minibuffer.
+	(tramp-completion-mode-p): Use `non-essential'.
+	(tramp-handle-file-name-all-completions): Backward/ XEmacs
+	compatibility: Use `completion-ignore-case' if
+	`read-file-name-completion-ignore-case' does not exist.
+	(tramp-get-debug-buffer): Use `tramp-debug-outline-regexp'.
+	(tramp-find-shell, tramp-open-connection-setup-interactive-shell):
+	`tramp-open-shell'.
+	(tramp-action-password): Hide password prompt before next run.
+	(tramp-process-actions): Widen connection buffer for the trace.
+	(tramp-open-connection-setup-interactive-shell): Set `remote-tty'
+	process property.  Trace stty settings if `tramp-verbose' >= 9.
+	Apply workaround for IRIX64 bug.  Move argument of last
+	`tramp-send-command' where it belongs to.
+	(tramp-maybe-open-connection): Use `async-args' and `gw-args' in
+	front of `login-args'.
+	(tramp-get-ls-command, tramp-get-ls-command-with-dired): Run tests
+	on "/dev/null" instead of "/".
+	(tramp-get-ls-command-with-dired): Make test for "--dired"
+	stronger.
+	(tramp-set-auto-save-file-modes): Adapt version check.
+	(tramp-set-process-query-on-exit-flag): Fix wrong parentheses.
+	(tramp-handle-process-file): Call the program in a subshell, in
+	order to preserve working directory.
+	(tramp-handle-shell-command): Don't use hard-wired "/bin/sh" but
+	`tramp-remote-sh' from `tramp-methods'.
+	(tramp-get-ls-command): Make test for "--color=never" stronger.
+	(tramp-check-for-regexp): Use (forward-line 1).
+
+	* net/trampver.el: Update release number.
+
+2010-08-26  Magnus Henoch  <magnus.henoch@gmail.com>
+
+	* net/tramp-gvfs.el (tramp-gvfs-handle-copy-file): Do not pass
+	empty argument to gvfs-copy.
+
+2010-08-26  Chong Yidong  <cyd@stupidchicken.com>
+
+	* net/tramp-compat.el (tramp-compat-delete-file): Rewrite to
+	handle new TRASH arg of `delete-file'.
+
+2010-08-26  Christian Lynbech  <christian.lynbech@tieto.com>  (tiny change)
+
+	* net/tramp.el (tramp-handle-insert-directory): Don't use
+	`forward-word', its default syntax could be changed.
+
+2010-08-26  Toru TSUNEYOSHI  <t_tuneyosi@hotmail.com>
+            Michael Albinus  <michael.albinus@gmx.de>
+
+	Implement compression for inline methods.
+
+	* net/tramp.el (tramp-inline-compress-start-size): New defcustom.
+	(tramp-copy-size-limit): Allow also nil.
+	(tramp-inline-compress-commands): New defconst.
+	(tramp-find-inline-compress, tramp-get-inline-compress)
+	(tramp-get-inline-coding): New defuns.
+	(tramp-get-remote-coding, tramp-get-local-coding): Remove,
+	replaced by `tramp-get-inline-coding'.
+	(tramp-handle-file-local-copy, tramp-handle-write-region)
+	(tramp-method-out-of-band-p): Use `tramp-get-inline-coding'.
+
+2010-08-26  Noah Lavine  <noah549@gmail.com>  (tiny change)
+
+	Detect ssh 'ControlMaster' argument automatically in some cases.
+
+	* net/tramp.el (tramp-detect-ssh-controlmaster): New defun.
+	(tramp-default-method): Use it.
+
+2010-08-26  Karel Klíč  <kklic@redhat.com>
+
+	* net/tramp.el (tramp-file-name-for-operation):
+	Add file-selinux-context.
+
+2010-08-26  Łukasz Stelmach  <lukasz.stelmach@iem.pw.edu.pl>  (tiny change)
+
+	* play/cookie1.el (read-cookie): Fix off-by-one error (bug#6921).
+
+2010-08-26  Chong Yidong  <cyd@stupidchicken.com>
+
+	* simple.el (beginning-of-buffer, end-of-buffer): Doc fix
+	(Bug#6907).
+
+2010-08-23  Chris Foote <chris@foote.com.au>  (tiny change)
+
+	* progmodes/python.el (python-block-pairs): Allow use of "finally"
+	with "else" (Bug#3991).
+
+2010-08-22  Leo  <sdl.web@gmail.com>
+
+	* net/rcirc.el (rcirc-add-or-remove): Accept a list of elements.
+	(ignore, bright, dim, keyword): Split list of nicknames before
+	passing to rcirc-add-or-remove (Bug#6894).
+
+2010-08-22  Chong Yidong  <cyd@stupidchicken.com>
+
+	* emacs-lisp/easy-mmode.el (define-minor-mode): Doc fix (Bug#6880).
+
+2010-08-21  Vinicius Jose Latorre  <viniciusjl@ig.com.br>
+
+	* whitespace.el: Fix slow cursor movement (Bug#6172).  Reported by
+	Christoph Groth <cwg@falma.de> and Liu Xin <x_liu@neusoft.com>.
+	New version 13.0.
+	(whitespace-empty-at-bob-regexp, whitespace-empty-at-eob-regexp):
+	Adjust initialization.
+	(whitespace-bob-marker, whitespace-eob-marker)
+	(whitespace-buffer-changed): New vars.
+	(whitespace-cleanup, whitespace-color-on, whitespace-color-off)
+	(whitespace-empty-at-bob-regexp, whitespace-empty-at-eob-regexp)
+	(whitespace-post-command-hook, whitespace-display-char-on):
+	Adjust code.
+	(whitespace-looking-back, whitespace-buffer-changed): New funs.
+	(whitespace-space-regexp, whitespace-tab-regexp): Eliminate funs.
+
+2010-08-21  Leo  <sdl.web@gmail.com>
+
+	Fix buffer-list rename&refresh after killing a buffer in ido.
+	* lisp/ido.el: Revert Óscar's.
+	(ido-kill-buffer-at-head): Exit the minibuffer with ido-exit=refresh.
+	Remember the buffers at head, rather than their name.
+	* lisp/iswitchb.el (iswitchb-kill-buffer): Re-make the list.
+
+2010-08-21  Kirk Kelsey  <kirk.kelsey@0x4b.net>  (tiny change)
+            Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* progmodes/make-mode.el (makefile-fill-paragraph): Account for the
+	extra backslash added to each line (bug#6890).
+
+2010-08-21  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* subr.el (read-key): Don't echo keystrokes (bug#6883).
+
+2010-08-21  Glenn Morris  <rgm@gnu.org>
+
+	* menu-bar.el (menu-bar-games-menu): Add landmark.
+
+2010-08-20  Glenn Morris  <rgm@gnu.org>
+
+	* align.el (align-regexp): Make group and spacing arguments
+	use the interactive defaults when non-interactive.  (Bug#6698)
+
+	* mail/rmail.el (rmail-forward): Replace mail-text-start with its
+	expansion, so as not to need sendmail.
+	(mail-text-start): Remove declaration.
+	(rmail-retry-failure): Require sendmail.
+
+2010-08-19  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* subr.el (read-key): Don't hide the menu-bar entries (bug#6881).
+
+2010-08-18  Michael Albinus  <michael.albinus@gmx.de>
+
+	* progmodes/flymake.el (flymake-start-syntax-check-process):
+	Use `start-file-process' in order to let it run also on remote hosts.
+
+2010-08-18  Kenichi Handa  <handa@m17n.org>
+
+	* files.el: Add `word-wrap' as safe local variable.
+
+2010-08-18  Glenn Morris  <rgm@gnu.org>
+
+	* woman.el (woman-translate): Case matters.  (Bug#6849)
+
+2010-08-14  Chong Yidong  <cyd@stupidchicken.com>
+
+	* simple.el (kill-region): Doc fix (Bug#6787).
+
+2010-08-14  Glenn Morris  <rgm@gnu.org>
+
+	* calendar/diary-lib.el (diary-header-line-format):
+	Fit it to the window, not the frame.
+
+2010-08-11  Andreas Schwab  <schwab@linux-m68k.org>
+
+	* subr.el (ignore-errors): Add debug declaration.
+
+2010-08-09  Geoff Gole  <geoffgole@gmail.com>  (tiny change)
+
+	* whitespace.el (whitespace-color-off): Remove post-command-hook
+	locally.
+
+2010-08-08  Johan Bockgård  <bojohan@gnu.org>
+
+	* replace.el (replace-highlight): Bind isearch-forward and
+	isearch-error, ensuring that highlighting is updated if the user
+	switches the search direction (Bug#6808).
+
+	* isearch.el (isearch-lazy-highlight-forward): New var.
+	(isearch-lazy-highlight-new-loop, isearch-lazy-highlight-search):
+	(isearch-lazy-highlight-update): Use it.
+
+2010-08-06  Kenichi Handa  <handa@m17n.org>
+
+	* international/mule.el (define-charset): Store NAME as :base property.
+	(ctext-non-standard-encodings-table): Pay attention to charset aliases.
+	(ctext-pre-write-conversion): Sort ctext-standard-encodings by the
+	current priority.  Force using the designation of the specific
+	charset by adding `charset' text property.  Improve the whole
+	algorithm.
+
+2010-08-05  Juanma Barranquero  <lekktu@gmail.com>
+
+	* emulation/pc-select.el (pc-selection-mode-hook)
+	(copy-region-as-kill-nomark, beginning-of-buffer-mark)
+	(pc-selection-mode): Fix typos in docstrings.
+
+2010-08-04  Kenichi Handa  <handa@m17n.org>
+
+	* language/cyrillic.el: Don't add "microsoft-cp1251" to
+	ctext-non-standard-encodings-alist here.
+
+	* international/mule.el (ctext-non-standard-encodings-alist):
+	Add "koi8-r" and "microsoft-cp1251".
+	(ctext-standard-encodings): New variable.
+	(ctext-non-standard-encodings-table): List only elements for
+	non-standard encodings.
+	(ctext-pre-write-conversion): Adjust for the above change.
+	Check ctext-standard-encodings.
+
+	* international/mule-conf.el (compound-text): Doc fix.
+	(ctext-no-compositions): Doc fix.
+	(compound-text-with-extensions): Doc fix.
+
+2010-08-04  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* simple.el (exchange-dot-and-mark): Mark obsolete, finally.
+
+2010-08-03  Juanma Barranquero  <lekktu@gmail.com>
+
+	* progmodes/which-func.el (which-func-format): Split help-echo text
+	into lines, like other mode-line tooltips.
+
+	* server.el (server-start): When using TCP sockets, force IPv4
+	and use a literal 127.0.0.1 for localhost.  (Related to bug#6781.)
+
+2010-08-02  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* bindings.el (complete-symbol): Run completion-at-point as a fallback.
+
+2010-08-02  Juanma Barranquero  <lekktu@gmail.com>
+
+	* term.el (term-delimiter-argument-list): Reflow docstring.
+	(term-read-input-ring, term-write-input-ring, term-send-input)
+	(term-bol, term-erase-in-display, serial-supported-or-barf):
+	Fix typos in docstrings.
+
+2010-08-02  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* bindings.el (function-key-map): Add a S-tab => backtab fallback.
+
+2010-08-01  Juanma Barranquero  <lekktu@gmail.com>
+
+	* dabbrev.el (dabbrev-completion): Fix typo in docstring.
+
+2010-08-01  MON KEY  <monkey@sandpframing.com>  (tiny change)
+
+	* emacs-lisp/syntax.el (syntax-ppss-toplevel-pos):
+	Fix typo in docstring (bug#6747).
+
+2010-07-30  Leo  <sdl.web@gmail.com>
+
+	* eshell/esh-io.el (eshell-get-target): Better detection of
+	read-only file (Bug#6762).
+
+2010-07-30  Juanma Barranquero  <lekktu@gmail.com>
+
+	* align.el (align-default-spacing): Doc fix.
+	(align-region-heuristic, align-regexp): Fix typos in docstrings.
+
 2010-07-23  Juanma Barranquero  <lekktu@gmail.com>
 
 	* help-fns.el (find-lisp-object-file-name): Doc fix (bug#6494).
@@ -2140,7 +2588,7 @@
 
 	* ps-print.el (ps-face-attributes): It was not returning the
 	attribute face for faces specified as string.  Reported by harven
-	<harven@free.fr>.
+	<harven@free.fr>.  (Bug#5254)
 	(ps-print-version): New version 7.3.5.
 
 2009-12-18  Ulf Jasper  <ulf.jasper@web.de>
--- a/lisp/align.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/align.el	Fri Aug 27 23:06:02 2010 +0900
@@ -1,7 +1,7 @@
 ;;; align.el --- align text to a specific column, by regexp
 
-;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+;;   2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <johnw@gnu.org>
 ;; Maintainer: FSF
@@ -140,8 +140,8 @@
   "An integer that represents the default amount of padding to use.
 If `align-to-tab-stop' is non-nil, this will represent the number of
 tab stops to use for alignment, rather than the number of spaces.
-Each alignment rule can optionally override both this variable.  See
-`align-mode-alist'."
+Each alignment rule can optionally override both this variable and
+`align-to-tab-stop'.  See `align-rules-list'."
   :type 'integer
   :group 'align)
 
@@ -157,8 +157,8 @@
 sections (whenever `align-region-separate' is non-nil, and not a
 string), this heuristic is used to determine how far before and after
 point we should search in looking for a region separator.  Larger
-values can mean slower perform in large files, although smaller values
-may cause unexpected behavior at times."
+values can mean slower performance in large files, although smaller
+values may cause unexpected behavior at times."
   :type 'integer
   :group 'align)
 
@@ -926,7 +926,7 @@
     Joe (123) 456-7890
 
 There is no predefined rule to handle this, but you could easily do it
-using a REGEXP like \"(\". All you would have to do is to mark the
+using a REGEXP like \"(\".  All you would have to do is to mark the
 region, call `align-regexp' and type in that regular expression."
   (interactive
    (append
@@ -944,6 +944,8 @@
       (list (concat "\\(\\s-*\\)"
 		    (read-string "Align regexp: "))
 	    1 align-default-spacing nil))))
+  (or group (setq group 1))
+  (or spacing (setq spacing align-default-spacing))
   (let ((rule
 	 (list (list nil (cons 'regexp regexp)
 		     (cons 'group (abs group))
--- a/lisp/bindings.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/bindings.el	Fri Aug 27 23:06:02 2010 +0900
@@ -688,6 +688,7 @@
 	      (fboundp 'semantic-active-p)
 	      (semantic-active-p))
 	 (semantic-ia-complete-symbol))
+        (completion-at-point-functions (completion-at-point))
 	(t
 	 (error "%s"
 		(substitute-command-keys
@@ -1035,6 +1036,9 @@
 ;; so we can't distinguish those two keys, but usually we consider C-SPC
 ;; (rather than C-@) as the "canonical" binding.
 (define-key function-key-map [?\C-@] [?\C-\s])
+;; Many keyboards don't have a `backtab' key, so by convention the user
+;; can use S-tab instead to access that binding.
+(define-key function-key-map [S-tab] [backtab])
 
 (define-key global-map [mouse-movement] 'ignore)
 
--- a/lisp/calendar/diary-lib.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/calendar/diary-lib.el	Fri Aug 27 23:06:02 2010 +0900
@@ -383,14 +383,14 @@
                      "Some text is hidden - press \"s\" in calendar \
 before edit/copy"
                    "Diary"))
-           ?\s (frame-width)))
+           ?\s (window-width)))
   "Format of the header line displayed by `diary-simple-display'.
 Only used if `diary-header-line-flag' is non-nil."
   :group 'diary
   :type 'sexp
   :initialize 'custom-initialize-default
   :set 'diary-set-header
-  :version "22.1")
+  :version "23.3")                      ; frame-width -> window-width
 
 ;; The first version of this also checked for diary-selective-display
 ;; in the non-fancy case. This was an attempt to distinguish between
--- a/lisp/dabbrev.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/dabbrev.el	Fri Aug 27 23:06:02 2010 +0900
@@ -377,7 +377,7 @@
 function pointed out by `dabbrev-friend-buffer-function' to find the
 completions.
 
-If the prefix argument is 16 (which comes from \\[prefix-argument] \\[prefix-argument]),
+If the prefix argument is 16 (which comes from \\[universal-argument] \\[universal-argument]),
 then it searches *all* buffers."
   (interactive "*P")
   (dabbrev--reset-global-variables)
--- a/lisp/emacs-lisp/easy-mmode.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/emacs-lisp/easy-mmode.el	Fri Aug 27 23:06:02 2010 +0900
@@ -86,25 +86,23 @@
 ;;;###autoload
 (defmacro define-minor-mode (mode doc &optional init-value lighter keymap &rest body)
   "Define a new minor mode MODE.
-This function defines the associated control variable MODE, keymap MODE-map,
-and toggle command MODE.
+This defines the control variable MODE and the toggle command MODE.
+DOC is the documentation for the mode toggle command.
 
-DOC is the documentation for the mode toggle command.
 Optional INIT-VALUE is the initial value of the mode's variable.
 Optional LIGHTER is displayed in the modeline when the mode is on.
-Optional KEYMAP is the default (defvar) keymap bound to the mode keymap.
-  If it is a list, it is passed to `easy-mmode-define-keymap'
-  in order to build a valid keymap.  It's generally better to use
-  a separate MODE-map variable than to use this argument.
-The above three arguments can be skipped if keyword arguments are
-used (see below).
+Optional KEYMAP is the default keymap bound to the mode keymap.
+  If non-nil, it should be a variable name (whose value is a keymap),
+  a keymap, or a list of arguments for `easy-mmode-define-keymap'.
+  If KEYMAP is a keymap or list, this also defines the variable MODE-map.
 
-BODY contains code to execute each time the mode is activated or deactivated.
-  It is executed after toggling the mode,
-  and before running the hook variable `MODE-hook'.
-  Before the actual body code, you can write keyword arguments (alternating
-  keywords and values).  These following keyword arguments are supported (other
-  keywords will be passed to `defcustom' if the minor mode is global):
+BODY contains code to execute each time the mode is enabled or disabled.
+  It is executed after toggling the mode, and before running MODE-hook.
+  Before the actual body code, you can write keyword arguments, i.e.
+  alternating keywords and values.  These following special keywords
+  are supported (other keywords are passed to `defcustom' if the minor
+  mode is global):
+
 :group GROUP	Custom group name to use in all generated `defcustom' forms.
 		Defaults to MODE without the possible trailing \"-mode\".
 		Don't use this default group name unless you have written a
--- a/lisp/emacs-lisp/syntax.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/emacs-lisp/syntax.el	Fri Aug 27 23:06:02 2010 +0900
@@ -52,7 +52,7 @@
 
 (defun syntax-ppss-toplevel-pos (ppss)
   "Get the latest syntactically outermost position found in a syntactic scan.
-PPSS is a scan state, as returned by `partial-parse-sexp' or `syntax-ppss'.
+PPSS is a scan state, as returned by `parse-partial-sexp' or `syntax-ppss'.
 An \"outermost position\" means one that it is outside of any syntactic entity:
 outside of any parentheses, comments, or strings encountered in the scan.
 If no such position is recorded in PPSS (because the end of the scan was
--- a/lisp/emulation/pc-select.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/emulation/pc-select.el	Fri Aug 27 23:06:02 2010 +0900
@@ -108,7 +108,7 @@
   :group 'pc-select)
 
 (defcustom pc-selection-mode-hook nil
-  "The hook to run when pc-selection-mode is toggled."
+  "The hook to run when PC Selection mode is toggled."
   :type 'hook
   :group 'pc-select)
 
@@ -259,7 +259,7 @@
 (provide 'pc-select)
 
 (defun copy-region-as-kill-nomark (beg end)
-  "Save the region as if killed; but don't kill it; deactivate mark.
+  "Save the region as if killed, but don't kill it; deactivate mark.
 If `interprogram-cut-function' is non-nil, also save the text for a window
 system cut and paste.
 
@@ -567,7 +567,7 @@
 ;;;;;;;;;;;;;;;;;;;;
 
 (defun backward-char-mark (&optional arg)
-"Ensure mark is active; move point left ARG characters (right if ARG negative).
+  "Ensure mark is active; move point left ARG characters (right if ARG negative).
 On attempt to pass beginning or end of buffer, stop and signal error."
   (interactive "p")
   (pc-select-ensure-mark)
@@ -631,7 +631,7 @@
 
 
 (defun scroll-up-mark (&optional arg)
-"Ensure mark is active; scroll upward ARG lines; or near full screen if no ARG.
+  "Ensure mark is active; scroll upward ARG lines; or near full screen if no ARG.
 A near full screen is `next-screen-context-lines' less than a full screen.
 Negative ARG means scroll downward.
 When calling from a program, supply a number as argument or nil.
@@ -652,7 +652,7 @@
 of the accessible part of the buffer.
 
 Don't use this command in Lisp programs!
-\(goto-char (p\oint-min)) is faster and avoids clobbering the mark."
+\(goto-char (point-min)) is faster and avoids clobbering the mark."
   (interactive "P")
   (pc-select-ensure-mark)
   (let ((size (- (point-max) (point-min))))
@@ -839,7 +839,7 @@
 
 ;;;###autoload
 (define-minor-mode pc-selection-mode
-  "Change mark behavior to emulate Motif, MAC or MS-Windows cut and paste style.
+  "Change mark behavior to emulate Motif, Mac or MS-Windows cut and paste style.
 
 This mode enables Delete Selection mode and Transient Mark mode.
 
--- a/lisp/eshell/esh-io.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/eshell/esh-io.el	Fri Aug 27 23:06:02 2010 +0900
@@ -343,8 +343,9 @@
 	(let* ((exists (get-file-buffer target))
 	       (buf (find-file-noselect target t)))
 	  (with-current-buffer buf
-	    (if buffer-read-only
+	    (if buffer-file-read-only
 		(error "Cannot write to read-only file `%s'" target))
+	    (setq buffer-read-only nil)
 	    (set (make-local-variable 'eshell-output-file-buffer)
 		 (if (eq exists buf) 0 t))
 	    (cond ((eq mode 'overwrite)
--- a/lisp/files.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/files.el	Fri Aug 27 23:06:02 2010 +0900
@@ -2774,7 +2774,8 @@
 	(left-margin          . integerp)   ;; C source code
 	(no-update-autoloads  . booleanp)
 	(tab-width            . integerp)   ;; C source code
-	(truncate-lines       . booleanp))) ;; C source code
+	(truncate-lines       . booleanp)   ;; C source code
+	(word-wrap            . booleanp))) ;; C source code
 
 (put 'c-set-style 'safe-local-eval-function t)
 
--- a/lisp/ido.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/ido.el	Fri Aug 27 23:06:02 2010 +0900
@@ -1042,11 +1042,11 @@
 ;; Stores the current list of items that will be searched through.
 ;; The list is ordered, so that the most interesting item comes first,
 ;; although by default, the files visible in the current frame are put
-;; at the end of the list.
-(defvar ido-cur-list nil)
+;; at the end of the list.  Created by `ido-make-item-list'.
+(defvar ido-cur-list)
 
 ;; Stores the choice list for ido-completing-read
-(defvar ido-choice-list nil)
+(defvar ido-choice-list)
 
 ;; Stores the list of items which are ignored when building
 ;; `ido-cur-list'.  It is in no specific order.
@@ -3348,12 +3348,9 @@
     (if ido-temp-list
 	(nconc ido-temp-list ido-current-buffers)
       (setq ido-temp-list ido-current-buffers))
-    (if (and default (buffer-live-p (get-buffer default)))
-	(progn
-	  (setq ido-temp-list
-		(delete default ido-temp-list))
-	  (setq ido-temp-list
-		(cons default ido-temp-list))))
+    (if default
+        (setq ido-temp-list
+              (cons default (delete default ido-temp-list))))
     (run-hooks 'ido-make-buffer-list-hook)
     ido-temp-list))
 
@@ -3594,7 +3591,6 @@
   ;; Used by `ido-get-buffers-in-frames' to walk through all windows
   (let ((buf (buffer-name (window-buffer win))))
 	(unless (or (member buf ido-bufs-in-frame)
-		    (minibufferp buf)
 		    (member buf ido-ignore-item-temp-list))
 	  ;; Only add buf if it is not already in list.
 	  ;; This prevents same buf in two different windows being
@@ -3835,27 +3831,6 @@
 	      ;;(add-hook 'completion-setup-hook 'completion-setup-function)
 	      (display-completion-list completion-list)))))))
 
-(defun ido-kill-buffer-internal (buf)
-  "Kill buffer BUF and rebuild ido's buffer list if needed."
-  (if (not (kill-buffer buf))
-      ;; buffer couldn't be killed.
-      (setq ido-rescan t)
-    ;; else buffer was killed so remove name from list.
-    (setq ido-cur-list (delq buf ido-cur-list))
-    ;; Some packages, like uniquify.el, may rename buffers when one
-    ;; is killed, so we need to test this condition to avoid using
-    ;; an outdated list of buffer names. We don't want to always
-    ;; rebuild the list of buffers, as this alters the previous
-    ;; buffer order that the user was seeing on the prompt. However,
-    ;; when we rebuild the list, we try to keep the previous second
-    ;; buffer as the first one.
-    (catch 'update
-      (dolist (b ido-cur-list)
-	(unless (get-buffer b)
-	  (setq ido-cur-list (ido-make-buffer-list (cadr ido-matches)))
-	  (setq ido-rescan t)
-	  (throw 'update nil))))))
-
 ;;; KILL CURRENT BUFFER
 (defun ido-kill-buffer-at-head ()
   "Kill the buffer at the head of `ido-matches'.
@@ -3864,15 +3839,26 @@
   (if (not (eobp))
       (delete-region (point) (line-end-position))
     (let ((enable-recursive-minibuffers t)
-	  (buf (ido-name (car ido-matches))))
-      (when buf
-	(ido-kill-buffer-internal buf)
-	;; Check if buffer still exists.
-	(if (get-buffer buf)
-	    ;; buffer couldn't be killed.
+	  (buf (ido-name (car ido-matches)))
+	  (nextbuf (cadr ido-matches)))
+      (when (get-buffer buf)
+	;; If next match names a buffer use the buffer object; buffer
+	;; name may be changed by packages such as uniquify; mindful
+	;; of virtual buffers.
+	(when (and nextbuf (get-buffer nextbuf))
+	  (setq nextbuf (get-buffer nextbuf)))
+	(if (null (kill-buffer buf))
+	    ;; Buffer couldn't be killed.
 	    (setq ido-rescan t)
-	  ;; else buffer was killed so remove name from list.
-	  (setq ido-cur-list (delq buf ido-cur-list)))))))
+	  ;; Else `kill-buffer' succeeds so re-make the buffer list
+	  ;; taking into account packages like uniquify may rename
+	  ;; buffers.
+	  (if (bufferp nextbuf)
+	      (setq nextbuf (buffer-name nextbuf)))
+	  (setq ido-default-item nextbuf
+		ido-text-init ido-text
+		ido-exit 'refresh)
+	  (exit-minibuffer))))))
 
 ;;; DELETE CURRENT FILE
 (defun ido-delete-file-at-head ()
@@ -3910,7 +3896,7 @@
      ((eq method 'kill)
       (if record
 	  (ido-record-command 'kill-buffer buffer))
-      (ido-kill-buffer-internal buffer))
+      (kill-buffer buffer))
 
      ((eq method 'other-window)
       (if record
--- a/lisp/international/mule-conf.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/international/mule-conf.el	Fri Aug 27 23:06:02 2010 +0900
@@ -1410,9 +1410,10 @@
   :flags '(ascii-at-eol ascii-at-cntl designation single-shift composition))
 
 (define-coding-system 'compound-text
-  "Compound text based generic encoding for decoding unknown messages.
-
-This coding system does not support extended segments of CTEXT."
+  "Compound text based generic encoding.
+This coding system is an extension of X's \"Compound Text Encoding\".
+It encodes many characters using the normal ISO-2022 designation sequences,
+but it doesn't support extended segments of CTEXT."
   :coding-type 'iso-2022
   :mnemonic ?x
   :charset-list 'iso-2022
@@ -1432,7 +1433,7 @@
 ;; not have a mime-charset property, to prevent it from showing up
 ;; close to the beginning of coding systems ordered by priority.
 (define-coding-system 'ctext-no-compositions
- "Compound text based generic encoding for decoding unknown messages.
+ "Compound text based generic encoding.
 
 Like `compound-text', but does not produce escape sequences for compositions."
   :coding-type 'iso-2022
@@ -1445,8 +1446,9 @@
 (define-coding-system 'compound-text-with-extensions
  "Compound text encoding with ICCCM Extended Segment extensions.
 
-See the variable `ctext-non-standard-encodings-alist' for the
-detail about how extended segments are handled.
+See the variables `ctext-standard-encodings' and
+`ctext-non-standard-encodings-alist' for the detail about how
+extended segments are handled.
 
 This coding system should be used only for X selections.  It is inappropriate
 for decoding and encoding files, process I/O, etc."
--- a/lisp/international/mule.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/international/mule.el	Fri Aug 27 23:06:02 2010 +0900
@@ -282,6 +282,7 @@
 	(plist-put props :short-name (symbol-name name)))
     (or (plist-get props :long-name)
 	(plist-put props :long-name (plist-get props :short-name)))
+    (plist-put props :base name)
     ;; We can probably get a worthwhile amount in purespace.
     (setq props
 	  (mapcar (lambda (elt)
@@ -1408,7 +1409,9 @@
   '(("big5-0" big5 2 big5)
     ("ISO8859-14" iso-8859-14 1 latin-iso8859-14)
     ("ISO8859-15" iso-8859-15 1 latin-iso8859-15)
-    ("gbk-0" gbk 2 chinese-gbk)))
+    ("gbk-0" gbk 2 chinese-gbk)
+    ("koi8-r" koi8-r 1 koi8-r)
+    ("microsoft-cp1251" windows-1251 1 windows-1251)))
   "Alist of non-standard encoding names vs the corresponding usages in CTEXT.
 
 It controls how extended segments of a compound text are handled
@@ -1497,6 +1500,20 @@
       (goto-char (point-min))
       (- (point-max) (point)))))
 
+(defvar ctext-standard-encodings
+  '(ascii latin-jisx0201 katakana-jisx0201
+	  latin-iso8859-1 latin-iso8859-2 latin-iso8859-3 latin-iso8859-4
+	  greek-iso8859-7 arabic-iso8859-6 hebrew-iso8859-8 cyrillic-iso8859-5
+	  latin-iso8859-9
+	  chinese-gb2312 japanese-jisx0208 korean-ksc5601)
+  "List of approved standard encodings (i.e. charsets) of X's Compound Text.
+Coding-system `compound-text-with-extensions' encodes a character
+belonging to any of those charsets using the normal ISO2022
+designation sequence unless the current language environment or
+the variable `ctext-non-standard-encodings' decide to use an extended
+segment of CTEXT for that character.  See also the documentation
+of `ctext-non-standard-encodings-alist'.")
+
 ;; Return an alist of CHARSET vs CTEXT-USAGE-INFO generated from
 ;; `ctext-non-standard-encodings' and a list specified by the key
 ;; `ctext-non-standard-encodings' for the currrent language
@@ -1508,115 +1525,94 @@
 ;; is encoded using UTF-8 encoding extention.
 
 (defun ctext-non-standard-encodings-table ()
-  (let (table)
-    ;; Setup charsets specified by the key
-    ;; `ctext-non-standard-encodings' for the current language
-    ;; environment and in `ctext-non-standard-encodings'.
-    (dolist (encoding (append
-			(get-language-info current-language-environment
-					   'ctext-non-standard-encodings)
-			ctext-non-standard-encodings))
-      (let* ((slot (assoc encoding ctext-non-standard-encodings-alist))
+  (let* ((table (append ctext-non-standard-encodings
+			(copy-sequence
+			 (get-language-info current-language-environment
+					    'ctext-non-standard-encodings))))
+	 (tail table)
+	 elt)
+    (while tail
+      (setq elt (car tail))
+      (let* ((slot (assoc elt ctext-non-standard-encodings-alist))
 	     (charset (nth 3 slot)))
 	(if (charsetp charset)
-	    (push (cons charset slot) table)
-	  (dolist (cs charset)
-	    (push (cons cs slot) table)))))
-
-    ;; Next prepend charsets for ISO2022 designation sequence.
-    (dolist (charset charset-list)
-      (let ((final (plist-get (charset-plist charset) :iso-final-char)))
-	(if (and (integerp final)
-		 (>= final #x40) (<= final #x7e)
-		 ;; Exclude ascii and chinese-cns11643-X.
-		 (not (eq charset 'ascii))
-		 (not (string-match "cns11643" (symbol-name charset))))
-	    (push (cons charset nil) table))))
-
-    ;; Returned reversed list so that the charsets specified by the
-    ;; key `ctext-non-standard-encodings' for the current language
-    ;; have the highest priority.
-    (nreverse table)))
+	    (setcar tail
+		    (cons (plist-get (charset-plist charset) :base) slot))
+	  (setcar tail (cons (car charset) slot))
+	  (dolist (cs (cdr charset))
+	    (setcdr tail
+		    (cons (cons (plist-get (charset-plist (car cs)) :base) slot)
+			  (cdr tail)))
+	    (setq tail (cdr tail))))
+	(setq tail (cdr tail))))
+    table))
 
 (defun ctext-pre-write-conversion (from to)
   "Encode characters between FROM and TO as Compound Text w/Extended Segments.
 
-If FROM is a string, or if the current buffer is not the one set up for us
-by `encode-coding-string', generate a new temp buffer, insert the text,
-and convert it in the temporary buffer.  Otherwise, convert in-place."
+If FROM is a string, generate a new temp buffer, insert the text,
+and convert it in the temporary buffer.  Otherwise, convert
+in-place."
   (save-match-data
     ;; Setup a working buffer if necessary.
     (when (stringp from)
       (set-buffer (generate-new-buffer " *temp"))
       (set-buffer-multibyte (multibyte-string-p from))
-      (insert from))
-
-    ;; Now we can encode the whole buffer.
-    (let ((encoding-table (ctext-non-standard-encodings-table))
-	  last-coding-system-used
-	  last-pos last-encoding-info
-	  encoding-info end-pos ch)
-      (goto-char (setq last-pos (point-min)))
-      (setq end-pos (point-marker))
-      (while (re-search-forward "[^\000-\177]+" nil t)
-	;; Found a sequence of non-ASCII characters.
-	(setq last-pos (match-beginning 0)
-	      ch (char-after last-pos)
-	      last-encoding-info (catch 'tag
-				   (dolist (elt encoding-table)
-				     (if (encode-char ch (car elt))
-					 (throw 'tag (cdr elt))))
-				   'utf-8))
-	(set-marker end-pos (match-end 0))
-	(goto-char (1+ last-pos))
-	(catch 'tag
-	  (while t
-	    (setq encoding-info
-		  (if (< (point) end-pos)
-		      (catch 'tag
-			(setq ch (following-char))
-			(dolist (elt encoding-table)
-			  (if (encode-char ch (car elt))
-			      (throw 'tag (cdr elt))))
-			'utf-8)))
-	    (unless (eq last-encoding-info encoding-info)
-	      (cond ((consp last-encoding-info)
-		     ;; Encode the previous range using an extended
-		     ;; segment.
-		     (let ((encoding-name (car last-encoding-info))
-			   (coding-system (nth 1 last-encoding-info))
-			   (noctets (nth 2 last-encoding-info))
-			   len)
-		       (encode-coding-region last-pos (point) coding-system)
-		       (setq len (+ (length encoding-name) 1
-				    (- (point) last-pos)))
-		       ;; According to the spec of CTEXT, it is not
-		       ;; necessary to produce this extra designation
-		       ;; sequence, but some buggy application
-		       ;; (e.g. crxvt-gb) requires it.
-		       (insert "\e(B")
-		       (save-excursion
-			 (goto-char last-pos)
-			 (insert (format "\e%%/%d" noctets))
-			 (insert-byte (+ (/ len 128) 128) 1)
-			 (insert-byte (+ (% len 128) 128) 1)
-			 (insert encoding-name)
-			 (insert 2))))
-		    ((eq last-encoding-info 'utf-8)
-		     ;; Encode the previous range using UTF-8 encoding
-		     ;; extention.
-		     (encode-coding-region last-pos (point) 'mule-utf-8)
-		     (save-excursion
-		       (goto-char last-pos)
-		       (insert "\e%G"))
-		     (insert "\e%@")))
-	      (setq last-pos (point)
-		    last-encoding-info encoding-info))
-	    (if (< (point) end-pos)
-		(forward-char 1)
-	      (throw 'tag nil)))))
-      (set-marker end-pos nil)
-      (goto-char (point-min))))
+      (insert from)
+      (setq from 1 to (point-max)))
+    (save-restriction
+      (narrow-to-region from to)
+      (goto-char from)
+      (let ((encoding-table (ctext-non-standard-encodings-table))
+	    (charset-list (sort-charsets
+			   (copy-sequence ctext-standard-encodings)))
+	    (end-pos (make-marker))
+	    last-coding-system-used
+	    last-pos charset encoding-info)
+	(dolist (elt encoding-table)
+	  (push (car elt) charset-list))
+	(setq end-pos (point-marker))
+	(while (re-search-forward "[^\0-\177]+" nil t)
+	  ;; Found a sequence of non-ASCII characters.
+	  (set-marker end-pos (match-end 0))
+	  (goto-char (match-beginning 0))
+	  (setq last-pos (point)
+		charset (char-charset (following-char) charset-list))
+	  (forward-char 1)
+	  (while (and (< (point) end-pos)
+		      (eq charset (char-charset (following-char) charset-list)))
+	    (forward-char 1))
+	  (if charset
+	      (if (setq encoding-info (cdr (assq charset encoding-table)))
+		  ;; Encode this range using an extended segment.
+		  (let ((encoding-name (car encoding-info))
+			(coding-system (nth 1 encoding-info))
+			(noctets (nth 2 encoding-info))
+			len)
+		    (encode-coding-region last-pos (point) coding-system)
+		    (setq len (+ (length encoding-name) 1
+				 (- (point) last-pos)))
+		    ;; According to the spec of CTEXT, it is not
+		    ;; necessary to produce this extra designation
+		    ;; sequence, but some buggy application
+		    ;; (e.g. crxvt-gb) requires it.
+		    (insert "\e(B")
+		    (save-excursion
+		      (goto-char last-pos)
+		      (insert (format "\e%%/%d" noctets))
+		      (insert-byte (+ (/ len 128) 128) 1)
+		      (insert-byte (+ (% len 128) 128) 1)
+		      (insert encoding-name)
+		      (insert 2)))
+		;; Encode this range as characters in CHARSET.
+		(put-text-property last-pos (point) 'charset charset))
+	    ;; Encode this range using UTF-8 encoding extention.
+	    (encode-coding-region last-pos (point) 'mule-utf-8)
+	    (save-excursion
+	      (goto-char last-pos)
+	      (insert "\e%G"))
+	    (insert "\e%@")))
+	(goto-char (point-min)))))
   ;; Must return nil, as build_annotations_2 expects that.
   nil)
 
--- a/lisp/isearch.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/isearch.el	Fri Aug 27 23:06:02 2010 +0900
@@ -2574,6 +2574,7 @@
 (defvar isearch-lazy-highlight-case-fold-search nil)
 (defvar isearch-lazy-highlight-regexp nil)
 (defvar isearch-lazy-highlight-space-regexp nil)
+(defvar isearch-lazy-highlight-forward nil)
 
 (defun lazy-highlight-cleanup (&optional force)
   "Stop lazy highlighting and remove extra highlighting from current buffer.
@@ -2613,7 +2614,9 @@
                  (not (= (window-start)
                          isearch-lazy-highlight-window-start))
                  (not (= (window-end)   ; Window may have been split/joined.
-                         isearch-lazy-highlight-window-end))))
+			 isearch-lazy-highlight-window-end))
+		 (not (eq isearch-forward
+			  isearch-lazy-highlight-forward))))
     ;; something important did indeed change
     (lazy-highlight-cleanup t) ;kill old loop & remove overlays
     (when (not isearch-error)
@@ -2628,7 +2631,8 @@
 	    isearch-lazy-highlight-case-fold-search isearch-case-fold-search
 	    isearch-lazy-highlight-regexp	isearch-regexp
             isearch-lazy-highlight-wrapped      nil
-	    isearch-lazy-highlight-space-regexp search-whitespace-regexp)
+	    isearch-lazy-highlight-space-regexp search-whitespace-regexp
+	    isearch-lazy-highlight-forward      isearch-forward)
       (unless (equal isearch-string "")
 	(setq isearch-lazy-highlight-timer
 	      (run-with-idle-timer lazy-highlight-initial-delay nil
@@ -2644,7 +2648,8 @@
 	    (search-invisible nil)	; don't match invisible text
 	    (retry t)
 	    (success nil)
-	    (bound (if isearch-forward
+	    (isearch-forward isearch-lazy-highlight-forward)
+	    (bound (if isearch-lazy-highlight-forward
 		       (min (or isearch-lazy-highlight-end-limit (point-max))
 			    (if isearch-lazy-highlight-wrapped
 				isearch-lazy-highlight-start
@@ -2678,7 +2683,7 @@
 	    (select-window isearch-lazy-highlight-window))
 	(save-excursion
 	  (save-match-data
-	    (goto-char (if isearch-forward
+	    (goto-char (if isearch-lazy-highlight-forward
 			   isearch-lazy-highlight-end
 			 isearch-lazy-highlight-start))
 	    (while looping
@@ -2691,7 +2696,7 @@
 		    (let ((mb (match-beginning 0))
 			  (me (match-end 0)))
 		      (if (= mb me)	;zero-length match
-			  (if isearch-forward
+			  (if isearch-lazy-highlight-forward
 			      (if (= mb (if isearch-lazy-highlight-wrapped
 					    isearch-lazy-highlight-start
 					  (window-end)))
@@ -2711,7 +2716,7 @@
 			  (overlay-put ov 'priority 1000)
 			  (overlay-put ov 'face lazy-highlight-face)
 			  (overlay-put ov 'window (selected-window))))
-		      (if isearch-forward
+		      (if isearch-lazy-highlight-forward
 			  (setq isearch-lazy-highlight-end (point))
 			(setq isearch-lazy-highlight-start (point)))))
 
@@ -2721,7 +2726,7 @@
 			(setq looping nil
 			      nomore  t)
 		      (setq isearch-lazy-highlight-wrapped t)
-		      (if isearch-forward
+		      (if isearch-lazy-highlight-forward
 			  (progn
 			    (setq isearch-lazy-highlight-end (window-start))
 			    (goto-char (max (or isearch-lazy-highlight-start-limit (point-min))
--- a/lisp/iswitchb.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/iswitchb.el	Fri Aug 27 23:06:02 2010 +0900
@@ -1027,8 +1027,8 @@
 (defun iswitchb-kill-buffer ()
   "Kill the buffer at the head of `iswitchb-matches'."
   (interactive)
-  (let ( (enable-recursive-minibuffers t)
-	 buf)
+  (let ((enable-recursive-minibuffers t)
+        buf)
 
     (setq buf (car iswitchb-matches))
     ;; check to see if buf is non-nil.
@@ -1042,8 +1042,10 @@
 	  (if (get-buffer buf)
 	      ;; buffer couldn't be killed.
 	      (setq iswitchb-rescan t)
-	    ;; else buffer was killed so remove name from list.
-	    (setq iswitchb-buflist  (delq buf iswitchb-buflist)))))))
+	    ;; Else `kill-buffer' succeeds so re-make the buffer list
+	    ;; taking into account packages like uniquify may rename
+	    ;; buffers
+	    (iswitchb-make-buflist iswitchb-default))))))
 
 ;;; VISIT CHOSEN BUFFER
 (defun iswitchb-visit-buffer (buffer)
--- a/lisp/language/cyrillic.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/language/cyrillic.el	Fri Aug 27 23:06:02 2010 +0900
@@ -239,13 +239,6 @@
 	   (documentation . "Support for Tajik using KOI8-T."))
  '("Cyrillic"))
 
-(let ((elt `("microsoft-cp1251" windows-1251 1
-	     ,(get 'encode-windows-1251 'translation-table)))
-      (slot (assoc "microsoft-cp1251" ctext-non-standard-encodings-alist)))
-  (if slot
-      (setcdr slot (cdr elt))
-    (push elt ctext-non-standard-encodings-alist)))
-
 (set-language-info-alist
  "Bulgarian" `((coding-system windows-1251)
 	       (coding-priority windows-1251)
--- a/lisp/mail/rmail.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/mail/rmail.el	Fri Aug 27 23:06:02 2010 +0900
@@ -191,8 +191,6 @@
   :group 'rmail-retrieve
   :type '(repeat (directory)))
 
-(declare-function mail-position-on-field "sendmail" (field &optional soft))
-(declare-function mail-text-start "sendmail" ())
 (declare-function rmail-dont-reply-to "mail-utils" (destinations))
 (declare-function rmail-update-summary "rmailsum" (&rest ignore))
 
@@ -1643,8 +1641,6 @@
 (declare-function rmail-summary-mark-deleted "rmailsum" (&optional n undel))
 (declare-function rfc822-addresses "rfc822" (header-text))
 (declare-function mail-abbrev-make-syntax-table "mailabbrev.el" ())
-(declare-function mail-sendmail-delimit-header "sendmail" ())
-(declare-function mail-header-end "sendmail" ())
 
 ;; RLK feature not added in this version:
 ;; argument specifies inbox file or files in various ways.
@@ -3686,7 +3682,8 @@
 	  ;; The mail buffer is now current.
 	  (save-excursion
 	    ;; Insert after header separator--before signature if any.
-	    (goto-char (mail-text-start))
+	    (rfc822-goto-eoh)
+	    (forward-line 1)
 	    (if (or rmail-enable-mime rmail-enable-mime-composing)
 		(funcall rmail-insert-mime-forwarded-message-function
 			 forward-buffer)
@@ -3841,6 +3838,10 @@
 			   (1- (point))
 			 (point-max)))))))
 
+(declare-function mail-sendmail-delimit-header "sendmail" ())
+(declare-function mail-header-end "sendmail" ())
+(declare-function mail-position-on-field "sendmail" (field &optional soft))
+
 (defun rmail-retry-failure ()
   "Edit a mail message which is based on the contents of the current message.
 For a message rejected by the mail system, extract the interesting headers and
@@ -3932,6 +3933,8 @@
 	    (goto-char (point-min))
 	    (if bounce-indent
 		(indent-rigidly (point-min) (point-max) bounce-indent))
+	    ;; FIXME better to replace sendmail functions.
+	    (require 'sendmail)
 	    (mail-sendmail-delimit-header)
 	    (save-restriction
 	      (narrow-to-region (point-min) (mail-header-end))
--- a/lisp/menu-bar.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/menu-bar.el	Fri Aug 27 23:06:02 2010 +0900
@@ -1191,6 +1191,9 @@
 (define-key menu-bar-games-menu [life]
   `(menu-item ,(purecopy "Life")  life
 	      :help ,(purecopy "Watch how John Conway's cellular automaton evolves")))
+(define-key menu-bar-games-menu [land]
+  `(menu-item ,(purecopy "Landmark") landmark
+	      :help ,(purecopy "Watch a neural-network robot learn landmarks")))
 (define-key menu-bar-games-menu [hanoi]
   `(menu-item ,(purecopy "Towers of Hanoi") hanoi
 	      :help ,(purecopy "Watch Towers-of-Hanoi puzzle solved by Emacs")))
--- a/lisp/net/rcirc.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/net/rcirc.el	Fri Aug 27 23:06:02 2010 +0900
@@ -1083,7 +1083,7 @@
     (when (not (equal 0 (- (point) rcirc-prompt-end-marker)))
       ;; delete a trailing newline
       (when (eq (point) (point-at-bol))
-	(delete-backward-char 1))
+	(delete-char -1))
       (let ((input (buffer-substring-no-properties
 		    rcirc-prompt-end-marker (point))))
 	(dolist (line (split-string input "\n"))
@@ -2110,12 +2110,13 @@
   (rcirc-send-string process (format "PRIVMSG %s :\C-aACTION %s\C-a"
                                      target args)))
 
-(defun rcirc-add-or-remove (set &optional elt)
-  (if (and elt (not (string= "" elt)))
-      (if (member-ignore-case elt set)
-	  (delete elt set)
-	(cons elt set))
-    set))
+(defun rcirc-add-or-remove (set &rest elements)
+  (dolist (elt elements)
+    (if (and elt (not (string= "" elt)))
+	(setq set (if (member-ignore-case elt set)
+		      (delete elt set)
+		    (cons elt set)))))
+  set)
 
 (defun-rcirc-command ignore (nick)
   "Manage the ignore list.
@@ -2123,7 +2124,9 @@
 nicks when no NICK is given.  When listing ignored nicks, the
 ones added to the list automatically are marked with an asterisk."
   (interactive "sToggle ignoring of nick: ")
-  (setq rcirc-ignore-list (rcirc-add-or-remove rcirc-ignore-list nick))
+  (setq rcirc-ignore-list
+	(apply #'rcirc-add-or-remove rcirc-ignore-list
+	       (split-string nick nil t)))
   (rcirc-print process nil "IGNORE" target
 	       (mapconcat
 		(lambda (nick)
@@ -2135,14 +2138,18 @@
 (defun-rcirc-command bright (nick)
   "Manage the bright nick list."
   (interactive "sToggle emphasis of nick: ")
-  (setq rcirc-bright-nicks (rcirc-add-or-remove rcirc-bright-nicks nick))
+  (setq rcirc-bright-nicks
+	(apply #'rcirc-add-or-remove rcirc-bright-nicks
+	       (split-string nick nil t)))
   (rcirc-print process nil "BRIGHT" target
 	       (mapconcat 'identity rcirc-bright-nicks " ")))
 
 (defun-rcirc-command dim (nick)
   "Manage the dim nick list."
   (interactive "sToggle deemphasis of nick: ")
-  (setq rcirc-dim-nicks (rcirc-add-or-remove rcirc-dim-nicks nick))
+  (setq rcirc-dim-nicks
+	(apply #'rcirc-add-or-remove rcirc-dim-nicks
+	       (split-string nick nil t)))
   (rcirc-print process nil "DIM" target
 	       (mapconcat 'identity rcirc-dim-nicks " ")))
 
@@ -2151,7 +2158,9 @@
 Mark KEYWORD, unmark KEYWORD if already marked, or list marked
 keywords when no KEYWORD is given."
   (interactive "sToggle highlighting of keyword: ")
-  (setq rcirc-keywords (rcirc-add-or-remove rcirc-keywords keyword))
+  (setq rcirc-keywords
+	(apply #'rcirc-add-or-remove rcirc-keywords
+	       (split-string keyword nil t)))
   (rcirc-print process nil "KEYWORD" target
 	       (mapconcat 'identity rcirc-keywords " ")))
 
--- a/lisp/net/tramp-cmds.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/net/tramp-cmds.el	Fri Aug 27 23:06:02 2010 +0900
@@ -106,8 +106,7 @@
   (setq tramp-locked nil)
 
   ;; Flush password cache.
-  (when (functionp 'password-reset)
-    (funcall (symbol-function 'password-reset)))
+  (tramp-compat-funcall 'password-reset)
 
   ;; Flush file and connection cache.
   (clrhash tramp-cache-data)
@@ -226,7 +225,7 @@
 This allows to investigate from a clean environment.  Another
 useful thing to do is to put
 
-  (setq tramp-verbose 8)
+  (setq tramp-verbose 9)
 
 in the ~/.emacs file and to repeat the bug.  Then, include the
 contents of the *tramp/foo* buffer and the *debug tramp/foo*
@@ -254,7 +253,7 @@
 			      (base64-encode-string val))))))
 
     ;; Dump variable.
-    (funcall (symbol-function 'reporter-dump-variable) varsym mailbuf)
+    (tramp-compat-funcall 'reporter-dump-variable varsym mailbuf)
 
     (unless (hash-table-p val)
       ;; Remove string quotation.
@@ -283,10 +282,8 @@
 	(load "mml" 'noerror))
     (require 'message nil 'noerror)
     (require 'mml nil 'noerror))
-  (when (functionp 'message-mode)
-    (funcall (symbol-function 'message-mode)))
-  (when (functionp 'mml-mode)
-    (funcall (symbol-function 'mml-mode) t)))
+  (tramp-compat-funcall 'message-mode)
+  (tramp-compat-funcall 'mml-mode t))
 
 (defun tramp-append-tramp-buffers ()
   "Append Tramp buffers and buffer local variables into the bug report."
@@ -308,15 +305,14 @@
 	(erase-buffer)
 	(insert "\n(setq\n")
 	(lisp-indent-line)
-	(funcall (symbol-function 'reporter-dump-variable)
-		 'buffer-name (current-buffer))
+	(tramp-compat-funcall
+	 'reporter-dump-variable 'buffer-name (current-buffer))
 	(dolist (varsym-or-cons-cell (buffer-local-variables buffer))
 	  (let ((varsym (or (car-safe varsym-or-cons-cell)
 			    varsym-or-cons-cell)))
 	    (when (string-match "tramp" (symbol-name varsym))
-	      (funcall
-	       (symbol-function 'reporter-dump-variable)
-	       varsym (current-buffer)))))
+	      (tramp-compat-funcall
+	       'reporter-dump-variable varsym (current-buffer)))))
 	(lisp-indent-line)
 	(insert ")\n"))
       (insert-buffer-substring elbuf)))
@@ -328,7 +324,7 @@
 	 (symbol-value 'mml-mode))
 
     (let ((tramp-buf-regexp "\\*\\(debug \\)?tramp/")
-	  (buffer-list (funcall (symbol-function 'tramp-list-tramp-buffers)))
+	  (buffer-list (tramp-compat-funcall 'tramp-list-tramp-buffers))
 	  (curbuf (current-buffer)))
 
       ;; There is at least one Tramp buffer.
@@ -376,10 +372,10 @@
 use another mail agent (by copying the contents of this buffer)
 please ensure that the buffers are attached to your email.\n\n")
 	      (dolist (buffer buffer-list)
-		(funcall (symbol-function 'mml-insert-empty-tag)
-			 'part 'type "text/plain" 'encoding "base64"
-			 'disposition "attachment" 'buffer buffer
-			 'description buffer))
+		(tramp-compat-funcall
+		 'mml-insert-empty-tag 'part 'type "text/plain"
+		 'encoding "base64" 'disposition "attachment" 'buffer buffer
+		 'description buffer))
 	      (set-buffer-modified-p nil))
 
 	  ;; Don't send.  Delete the message buffer.
--- a/lisp/net/tramp-compat.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/net/tramp-compat.el	Fri Aug 27 23:06:02 2010 +0900
@@ -22,9 +22,9 @@
 
 ;;; Commentary:
 
-;; Tramp's main Emacs version for development is GNU Emacs 23.  This
-;; package provides compatibility functions for GNU Emacs 21, GNU
-;; Emacs 22 and XEmacs 21.4+.
+;; Tramp's main Emacs version for development is GNU Emacs 24.  This
+;; package provides compatibility functions for GNU Emacs 22, GNU
+;; Emacs 23 and XEmacs 21.4+.
 
 ;;; Code:
 
@@ -44,33 +44,31 @@
 
   (autoload 'tramp-tramp-file-p "tramp")
   (autoload 'tramp-file-name-handler "tramp")
-  (autoload 'tramp-handle-file-remote-p "tramp")
+
+  ;; We check whether `start-file-process' is bound.
+  (unless (fboundp 'start-file-process)
 
-  ;; tramp-util offers integration into other (X)Emacs packages like
-  ;; compile.el, gud.el etc.  Not necessary in Emacs 23.
-  (eval-after-load "tramp"
-    ;; We check whether `start-file-process' is an alias.
-    '(when (or (not (fboundp 'start-file-process))
-	       (symbolp (symbol-function 'start-file-process)))
-       (require 'tramp-util)
-       (add-hook 'tramp-unload-hook
-		 '(lambda ()
-		    (when (featurep 'tramp-util)
-		      (unload-feature 'tramp-util 'force))))))
-
-  ;; Make sure that we get integration with the VC package.  When it
-  ;; is loaded, we need to pull in the integration module.  Not
-  ;; necessary in Emacs 23.
-  (eval-after-load "vc"
+    ;; tramp-util offers integration into other (X)Emacs packages like
+    ;; compile.el, gud.el etc.  Not necessary in Emacs 23.
     (eval-after-load "tramp"
-      ;; We check whether `start-file-process' is an alias.
-      '(when (or (not (fboundp 'start-file-process))
-		 (symbolp (symbol-function 'start-file-process)))
-	 (require 'tramp-vc)
+      '(progn
+	 (require 'tramp-util)
 	 (add-hook 'tramp-unload-hook
 		   '(lambda ()
-		      (when (featurep 'tramp-vc)
-			(unload-feature 'tramp-vc 'force)))))))
+		      (when (featurep 'tramp-util)
+			(unload-feature 'tramp-util 'force))))))
+
+    ;; Make sure that we get integration with the VC package.  When it
+    ;; is loaded, we need to pull in the integration module.  Not
+    ;; necessary in Emacs 23.
+    (eval-after-load "vc"
+      (eval-after-load "tramp"
+	'(progn
+	   (require 'tramp-vc)
+	   (add-hook 'tramp-unload-hook
+		     '(lambda ()
+			(when (featurep 'tramp-vc)
+			  (unload-feature 'tramp-vc 'force))))))))
 
   ;; Avoid byte-compiler warnings if the byte-compiler supports this.
   ;; Currently, XEmacs supports this.
@@ -89,14 +87,25 @@
   (unless (boundp 'byte-compile-not-obsolete-var)
     (defvar byte-compile-not-obsolete-var nil))
   (setq byte-compile-not-obsolete-var 'directory-sep-char)
-  (if (boundp 'byte-compile-not-obsolete-vars) ; Emacs 23.2
-      (setq byte-compile-not-obsolete-vars '(directory-sep-char)))
+  ;; Emacs 23.2.
+  (unless (boundp 'byte-compile-not-obsolete-vars)
+    (defvar byte-compile-not-obsolete-vars nil))
+  (setq byte-compile-not-obsolete-vars '(directory-sep-char))
 
   ;; `with-temp-message' does not exists in XEmacs.
   (condition-case nil
       (with-temp-message (current-message) nil)
     (error (defmacro with-temp-message (message &rest body) `(progn ,@body))))
 
+  ;; For not existing functions, or functions with a changed argument
+  ;; list, there are compiler warnings.  We want to avoid them in
+  ;; cases we know what we do.
+  (defmacro tramp-compat-funcall (function &rest arguments)
+    (if (featurep 'xemacs)
+	`(funcall (symbol-function ,function) ,@arguments)
+      `(when (or (subrp ,function) (functionp ,function))
+	 (with-no-warnings (funcall ,function ,@arguments)))))
+
   ;; `set-buffer-multibyte' comes from Emacs Leim.
   (unless (fboundp 'set-buffer-multibyte)
     (defalias 'set-buffer-multibyte 'ignore))
@@ -120,7 +129,7 @@
 	  (tramp-file-name-handler
 	   'file-remote-p file identification connected)))))
 
-  ;; `process-file' exists since Emacs 22.
+  ;; `process-file' does not exist in XEmacs.
   (unless (fboundp 'process-file)
     (defalias 'process-file
       (lambda (program &optional infile buffer display &rest args)
@@ -154,7 +163,9 @@
   ;; return the original filename if it can't expand anything.  Let's
   ;; just hope that this doesn't break anything else.
   ;; It is not needed anymore since GNU Emacs 23.2.
-  (unless (or (featurep 'xemacs) (featurep 'files 'remote-wildcards))
+  (unless (or (featurep 'xemacs)
+	      ;; `featurep' has only one argument in XEmacs.
+	      (funcall 'featurep 'files 'remote-wildcards))
     (defadvice file-expand-wildcards
       (around tramp-advice-file-expand-wildcards activate)
       (let ((name (ad-get-arg 0)))
@@ -163,7 +174,8 @@
 	(if (and
 	     (tramp-tramp-file-p name)
 	     (not (string-match
-		   "[[*?]" (tramp-handle-file-remote-p name 'localname))))
+		   "[[*?]" (tramp-compat-funcall
+			    'file-remote-p name 'localname))))
 	    (setq ad-return-value (list name))
 	  ;; Otherwise, just run the original function.
 	  ad-do-it)))
@@ -180,8 +192,8 @@
 own implementation."
   (cond
    ((fboundp 'line-beginning-position)
-    (funcall (symbol-function 'line-beginning-position)))
-   ((fboundp 'point-at-bol) (funcall (symbol-function 'point-at-bol)))
+    (tramp-compat-funcall 'line-beginning-position))
+   ((fboundp 'point-at-bol) (tramp-compat-funcall 'point-at-bol))
    (t (save-excursion (beginning-of-line) (point)))))
 
 (defsubst tramp-compat-line-end-position ()
@@ -189,8 +201,8 @@
 Calls `line-end-position' or `point-at-eol' if defined, else
 own implementation."
   (cond
-   ((fboundp 'line-end-position) (funcall (symbol-function 'line-end-position)))
-   ((fboundp 'point-at-eol) 	 (funcall (symbol-function 'point-at-eol)))
+   ((fboundp 'line-end-position) (tramp-compat-funcall 'line-end-position))
+   ((fboundp 'point-at-eol) (tramp-compat-funcall 'point-at-eol))
    (t (save-excursion (end-of-line) (point)))))
 
 (defsubst tramp-compat-temporary-file-directory ()
@@ -199,7 +211,7 @@
 this is the function `temp-directory'."
   (cond
    ((boundp 'temporary-file-directory) (symbol-value 'temporary-file-directory))
-   ((fboundp 'temp-directory) (funcall (symbol-function 'temp-directory)))
+   ((fboundp 'temp-directory) (tramp-compat-funcall 'temp-directory))
    ((let ((d (getenv "TEMP"))) (and d (file-directory-p d)))
     (file-name-as-directory (getenv "TEMP")))
    ((let ((d (getenv "TMP"))) (and d (file-directory-p d)))
@@ -211,10 +223,9 @@
 		       "`temp-directory' is defined -- using /tmp."))
       (file-name-as-directory "/tmp"))))
 
-;; `make-temp-file' exists in Emacs only.  The third parameter SUFFIX
-;; has been introduced with Emacs 22.  We try it, if it fails, we fall
-;; back to `make-temp-name', creating the temporary file immediately
-;; in order to avoid a security hole.
+;; `make-temp-file' exists in Emacs only.  On XEmacs, we use our own
+;; implementation with `make-temp-name', creating the temporary file
+;; immediately in order to avoid a security hole.
 (defsubst tramp-compat-make-temp-file (filename &optional dir-flag)
   "Create a temporary file (compat function).
 Add the extension of FILENAME, if existing."
@@ -226,8 +237,7 @@
 	 result)
     (condition-case nil
 	(setq result
-	      (funcall
-	       (symbol-function 'make-temp-file) prefix dir-flag extension))
+	      (tramp-compat-funcall 'make-temp-file prefix dir-flag extension))
       (error
        ;; We use our own implementation, taken from files.el.
        (while
@@ -236,14 +246,7 @@
 		 (setq result (concat (make-temp-name prefix) extension))
 		 (if dir-flag
 		     (make-directory result)
-		   (write-region
-		    "" nil result nil 'silent nil
-		    ;; 7th parameter is MUSTBENEW in Emacs, and
-		    ;; CODING-SYSTEM in XEmacs.  It is not a security
-		    ;; hole in XEmacs if we cannot use this parameter,
-		    ;; because XEmacs uses a user-specific
-		    ;; subdirectory with 0700 permissions.
-		    (when (not (featurep 'xemacs)) 'excl)))
+		   (write-region "" nil result nil 'silent))
 		 nil)
 	     (file-already-exists t))
 	 ;; The file was somehow created by someone else between
@@ -251,16 +254,15 @@
 	 nil)))
     result))
 
-;; `most-positive-fixnum' arrived in Emacs 22.  Before, and in XEmacs,
-;; it is a fixed value.
+;; `most-positive-fixnum' does not exist in XEmacs.
 (defsubst tramp-compat-most-positive-fixnum ()
   "Return largest positive integer value (compat function)."
   (cond
    ((boundp 'most-positive-fixnum) (symbol-value 'most-positive-fixnum))
-   ;; Default value in XEmacs and Emacs 21.
+   ;; Default value in XEmacs.
    (t 134217727)))
 
-;; ID-FORMAT exists since Emacs 22.
+;; ID-FORMAT does not exists in XEmacs.
 (defun tramp-compat-file-attributes (filename &optional id-format)
   "Like `file-attributes' for Tramp files (compat function)."
   (cond
@@ -269,19 +271,27 @@
    ((tramp-tramp-file-p filename)
     (tramp-file-name-handler 'file-attributes filename id-format))
    (t (condition-case nil
-	  (funcall (symbol-function 'file-attributes) filename id-format)
-	(error (file-attributes filename))))))
+	  (tramp-compat-funcall 'file-attributes filename id-format)
+	(wrong-number-of-arguments (file-attributes filename))))))
 
 ;; PRESERVE-UID-GID has been introduced with Emacs 23.  It does not
 ;; hurt to ignore it for other (X)Emacs versions.
+;; PRESERVE-SELINUX-CONTEXT has been introduced with Emacs 24.
 (defun tramp-compat-copy-file
-  (filename newname &optional ok-if-already-exists keep-date preserve-uid-gid)
+  (filename newname &optional ok-if-already-exists keep-date
+	    preserve-uid-gid preserve-selinux-context)
   "Like `copy-file' for Tramp files (compat function)."
-  (if preserve-uid-gid
-      (funcall
-       (symbol-function 'copy-file)
-       filename newname ok-if-already-exists keep-date preserve-uid-gid)
-    (copy-file filename newname ok-if-already-exists keep-date)))
+  (cond
+   (preserve-selinux-context
+    (tramp-compat-funcall
+     'copy-file filename newname ok-if-already-exists keep-date
+     preserve-uid-gid preserve-selinux-context))
+   (preserve-uid-gid
+    (tramp-compat-funcall
+     'copy-file filename newname ok-if-already-exists keep-date
+     preserve-uid-gid))
+   (t
+    (copy-file filename newname ok-if-already-exists keep-date))))
 
 ;; `copy-directory' is a new function in Emacs 23.2.  Implementation
 ;; is taken from there.
@@ -289,11 +299,10 @@
   (directory newname &optional keep-time parents)
   "Make a copy of DIRECTORY (compat function)."
   (if (fboundp 'copy-directory)
-      (funcall
-       (symbol-function 'copy-directory) directory newname keep-time parents)
+      (tramp-compat-funcall 'copy-directory directory newname keep-time parents)
 
-    ;; If default-directory is a remote directory, make sure we find
-    ;; its copy-directory handler.
+    ;; If `default-directory' is a remote directory, make sure we find
+    ;; its `copy-directory' handler.
     (let ((handler (or (find-file-name-handler directory 'copy-directory)
 		       (find-file-name-handler newname 'copy-directory))))
       (if handler
@@ -325,36 +334,45 @@
 	(if keep-time
 	    (set-file-times newname (nth 5 (file-attributes directory))))))))
 
-;; `copy-tree' is a built-in function in XEmacs.  In Emacs 21, it is
-;; an autoloaded function in cl-extra.el.  Since Emacs 22, it is part
-;; of subr.el.  There are problems when autoloading, therefore we test
-;; for `subrp' and `symbol-file'.  Implementation is taken from Emacs 23.
-(defun tramp-compat-copy-tree (tree)
-  "Make a copy of TREE (compat function)."
-  (if (or (subrp 'copy-tree) (symbol-file 'copy-tree))
-      (funcall (symbol-function 'copy-tree) tree)
-    (let (result)
-      (while (consp tree)
-	(let ((newcar (car tree)))
-	  (if (consp (car tree))
-	      (setq newcar (tramp-compat-copy-tree (car tree))))
-	  (push newcar result))
-	(setq tree (cdr tree)))
-      (nconc (nreverse result) tree))))
+;; TRASH has been introduced with Emacs 24.1.
+(defun tramp-compat-delete-file (filename &optional trash)
+  "Like `delete-file' for Tramp files (compat function)."
+  (condition-case nil
+      (tramp-compat-funcall 'delete-file filename trash)
+    ;; This Emacs version does not support the TRASH flag.
+    (wrong-number-of-arguments
+     (let ((delete-by-moving-to-trash
+	    (and (boundp 'delete-by-moving-to-trash)
+		 (symbol-value 'delete-by-moving-to-trash)
+		 trash)))
+       (delete-file filename)))))
 
 ;; RECURSIVE has been introduced with Emacs 23.2.
 (defun tramp-compat-delete-directory (directory &optional recursive)
   "Like `delete-directory' for Tramp files (compat function)."
-  (if recursive
-      (funcall (symbol-function 'delete-directory) directory recursive)
-    (delete-directory directory)))
+  (if (null recursive)
+      (delete-directory directory)
+    (condition-case nil
+	(tramp-compat-funcall 'delete-directory directory recursive)
+      ;; This Emacs version does not support the RECURSIVE flag.  We
+      ;; use the implementation from Emacs 23.2.
+      (wrong-number-of-arguments
+       (setq directory (directory-file-name (expand-file-name directory)))
+       (if (not (file-symlink-p directory))
+	   (mapc (lambda (file)
+		   (if (eq t (car (file-attributes file)))
+		       (tramp-compat-delete-directory file recursive)
+		     (delete-file file)))
+		 (directory-files
+		  directory 'full "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*")))
+       (delete-directory directory)))))
 
-;; `number-sequence' has been introduced in Emacs 22.  Implementation
-;; is taken from Emacs 23.
+;; `number-sequence' does not exist in XEmacs.  Implementation is
+;; taken from Emacs 23.
 (defun tramp-compat-number-sequence (from &optional to inc)
   "Return a sequence of numbers from FROM to TO as a list (compat function)."
   (if (or (subrp 'number-sequence) (symbol-file 'number-sequence))
-      (funcall (symbol-function 'number-sequence) from to inc)
+      (tramp-compat-funcall 'number-sequence from to inc)
     (if (or (not to) (= from to))
 	(list from)
       (or inc (setq inc 1))
@@ -384,15 +402,13 @@
     (cond
      ;; GNU Emacs 22 on w32.
      ((fboundp 'w32-window-exists-p)
-      (funcall (symbol-function 'w32-window-exists-p)
-	       process-name process-name))
+      (tramp-compat-funcall 'w32-window-exists-p process-name process-name))
 
      ;; GNU Emacs 23.
      ((and (fboundp 'list-system-processes) (fboundp 'process-attributes))
       (let (result)
-	(dolist (pid (funcall (symbol-function 'list-system-processes)) result)
-	  (let ((attributes
-		 (funcall (symbol-function 'process-attributes) pid)))
+	(dolist (pid (tramp-compat-funcall 'list-system-processes) result)
+	  (let ((attributes (tramp-compat-funcall 'process-attributes pid)))
 	    (when (and (string-equal
                         (cdr (assoc 'user attributes)) (user-login-name))
                        (let ((comm (cdr (assoc 'comm attributes))))
--- a/lisp/net/tramp-fish.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/net/tramp-fish.el	Fri Aug 27 23:06:02 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)
@@ -217,7 +220,6 @@
     (file-executable-p . tramp-fish-handle-file-executable-p)
     (file-exists-p . tramp-fish-handle-file-exists-p)
     (file-local-copy . tramp-fish-handle-file-local-copy)
-    (file-remote-p . tramp-handle-file-remote-p)
     (file-modes . tramp-handle-file-modes)
     (file-name-all-completions . tramp-fish-handle-file-name-all-completions)
     (file-name-as-directory . tramp-handle-file-name-as-directory)
@@ -229,6 +231,8 @@
     (file-ownership-preserved-p . ignore)
     (file-readable-p . tramp-fish-handle-file-readable-p)
     (file-regular-p . tramp-handle-file-regular-p)
+    (file-remote-p . tramp-handle-file-remote-p)
+    ;; `file-selinux-context' performed by default handler.
     (file-symlink-p . tramp-handle-file-symlink-p)
     ;; `file-truename' performed by default handler
     (file-writable-p . tramp-fish-handle-file-writable-p)
@@ -243,6 +247,7 @@
     (make-symbolic-link . tramp-fish-handle-make-symbolic-link)
     (rename-file . tramp-fish-handle-rename-file)
     (set-file-modes . tramp-fish-handle-set-file-modes)
+    ;; `set-file-selinux-context' performed by default handler.
     (set-file-times . tramp-fish-handle-set-file-times)
     (set-visited-file-modtime . ignore)
     (shell-command . tramp-handle-shell-command)
@@ -307,7 +312,8 @@
 	 v1 'file-error "Error with add-name-to-file %s" newname)))))
 
 (defun tramp-fish-handle-copy-file
-  (filename newname &optional ok-if-already-exists keep-date preserve-uid-gid)
+  (filename newname &optional ok-if-already-exists keep-date
+	    preserve-uid-gid preserve-selinux-context)
   "Like `copy-file' for Tramp files."
   (tramp-fish-do-copy-or-rename-file
    'copy filename newname ok-if-already-exists keep-date preserve-uid-gid))
@@ -324,12 +330,12 @@
 	 ;; We do not want to delete "." and "..".
 	 (directory-files
 	  directory 'full "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*")))
-     (with-parsed-tramp-file-name
+    (with-parsed-tramp-file-name
 	(directory-file-name (expand-file-name directory)) nil
       (tramp-flush-directory-property v localname)
       (tramp-fish-send-command-and-check v (format "#RMD %s" localname)))))
 
-(defun tramp-fish-handle-delete-file (filename)
+(defun tramp-fish-handle-delete-file (filename &optional trash)
   "Like `delete-file' for Tramp files."
   (when (file-exists-p filename)
     (with-parsed-tramp-file-name (expand-file-name filename) nil
@@ -341,10 +347,10 @@
   "Like `directory-files-and-attributes' for Tramp files."
   (mapcar
    (lambda (x)
-     ;; We cannot call `file-attributes' for backward compatibility reasons.
-     ;; Its optional parameter ID-FORMAT is introduced with Emacs 22.
-     (cons x (tramp-fish-handle-file-attributes
-	(if full x (expand-file-name x directory)) id-format)))
+     (cons x
+	   (tramp-compat-file-attributes
+	    (if full x (expand-file-name x directory))
+	    id-format)))
    (directory-files directory full match nosort)))
 
 (defun tramp-fish-handle-expand-file-name (name &optional dir)
@@ -484,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.
@@ -588,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)))))
 
@@ -1030,15 +1035,15 @@
 	 ;; last line
 	 ((looking-at "^$")
 	  (return)))
-	;; delete line
+	;; Delete line.
 	(forward-line)
 	(delete-region (point-min) (point))))
 
-    ;; delete trailing empty line
+    ;; Delete trailing empty line.
     (forward-line)
     (delete-region (point-min) (point))
 
-    ;; Return entry in file-attributes format
+    ;; Return entry in `file-attributes' format.
     (list localname link -1 uid gid '(0 0) mtime '(0 0) size mode nil)))
 
 (defun tramp-fish-retrieve-data (vec)
@@ -1112,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-ftp.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/net/tramp-ftp.el	Fri Aug 27 23:06:02 2010 +0900
@@ -1,7 +1,7 @@
 ;;; tramp-ftp.el --- Tramp convenience functions for Ange-FTP
 
-;; Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007,
-;;   2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+;;   2009, 2010 Free Software Foundation, Inc.
 
 ;; Author: Michael Albinus <michael.albinus@gmx.de>
 ;; Keywords: comm, processes
--- a/lisp/net/tramp-gvfs.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/net/tramp-gvfs.el	Fri Aug 27 23:06:02 2010 +0900
@@ -28,6 +28,10 @@
 ;; incompatibility with the mount_info structure, which has been
 ;; worked around.
 
+;; It has also been tested with GVFS 1.6.2 (Ubuntu 10.04, Gnome 2.30),
+;; where the default_location has been added to mount_info (see
+;; <https://bugzilla.gnome.org/show_bug.cgi?id=561998>.
+
 ;; All actions to mount a remote location, and to retrieve mount
 ;; information, are performed by D-Bus messages.  File operations
 ;; themselves are performed via the mounted filesystem in ~/.gvfs.
@@ -100,6 +104,7 @@
 (require 'tramp)
 (require 'dbus)
 (require 'url-parse)
+(require 'url-util)
 (require 'zeroconf)
 
 (defcustom tramp-gvfs-methods '("dav" "davs" "obex" "synce")
@@ -133,10 +138,6 @@
        (unless (assoc elt tramp-methods)
 	 (add-to-list 'tramp-methods (cons elt nil))))))
 
-(defconst tramp-gvfs-mount-point
-  (file-name-as-directory (expand-file-name ".gvfs" "~/"))
-  "The directory name, fuses mounts remote ressources.")
-
 (defconst tramp-gvfs-path-tramp (concat dbus-path-emacs "/Tramp")
   "The preceeding object path for own objects.")
 
@@ -156,7 +157,7 @@
 ;; <interface name='org.gtk.vfs.MountTracker'>
 ;;   <method name='listMounts'>
 ;;     <arg name='mount_info_list'
-;;          type='a{sosssssbay{aya{say}}}'
+;;          type='a{sosssssbay{aya{say}}ay}'
 ;;          direction='out'/>
 ;;   </method>
 ;;   <method name='mountLocation'>
@@ -166,11 +167,11 @@
 ;;   </method>
 ;;   <signal name='mounted'>
 ;;     <arg name='mount_info'
-;;          type='{sosssssbay{aya{say}}}'/>
+;;          type='{sosssssbay{aya{say}}ay}'/>
 ;;   </signal>
 ;;   <signal name='unmounted'>
 ;;     <arg name='mount_info'
-;;          type='{sosssssbay{aya{say}}}'/>
+;;          type='{sosssssbay{aya{say}}ay}'/>
 ;;   </signal>
 ;; </interface>
 ;;
@@ -190,6 +191,7 @@
 ;;       STRUCT		    mount_spec_item
 ;;         STRING	      key (server, share, type, user, host, port)
 ;;         ARRAY BYTE	      value
+;;   ARRAY BYTE           default_location	Since GVFS 1.5 only !!!
 
 (defconst tramp-gvfs-interface-mountoperation "org.gtk.vfs.MountOperation"
   "Used by the dbus-proxying implementation of GMountOperation.")
@@ -386,7 +388,6 @@
     (file-executable-p . tramp-gvfs-handle-file-executable-p)
     (file-exists-p . tramp-gvfs-handle-file-exists-p)
     (file-local-copy . tramp-gvfs-handle-file-local-copy)
-    (file-remote-p . tramp-handle-file-remote-p)
     ;; `file-modes' performed by default handler.
     (file-name-all-completions . tramp-gvfs-handle-file-name-all-completions)
     (file-name-as-directory . tramp-handle-file-name-as-directory)
@@ -398,6 +399,8 @@
     (file-ownership-preserved-p . ignore)
     (file-readable-p . tramp-gvfs-handle-file-readable-p)
     (file-regular-p . tramp-handle-file-regular-p)
+    (file-remote-p . tramp-handle-file-remote-p)
+    (file-selinux-context . tramp-gvfs-handle-file-selinux-context)
     (file-symlink-p . tramp-handle-file-symlink-p)
     ;; `file-truename' performed by default handler.
     (file-writable-p . tramp-gvfs-handle-file-writable-p)
@@ -413,6 +416,7 @@
     (process-file . tramp-gvfs-handle-process-file)
     (rename-file . tramp-gvfs-handle-rename-file)
     (set-file-modes . tramp-gvfs-handle-set-file-modes)
+    (set-file-selinux-context . tramp-gvfs-handle-set-file-selinux-context)
     (set-visited-file-modtime . tramp-gvfs-handle-set-visited-file-modtime)
     (shell-command . tramp-gvfs-handle-shell-command)
     (start-file-process . tramp-gvfs-handle-start-file-process)
@@ -447,6 +451,17 @@
 (add-to-list 'tramp-foreign-file-name-handler-alist
 	     (cons 'tramp-gvfs-file-name-p 'tramp-gvfs-file-name-handler))
 
+(defun tramp-gvfs-stringify-dbus-message (message)
+  "Convert a D-Bus message into readable UTF8 strings, used for traces."
+  (cond
+   ((and (consp message) (characterp (car message)))
+    (format "%S" (dbus-byte-array-to-string message)))
+   ((consp message)
+    (mapcar 'tramp-gvfs-stringify-dbus-message message))
+   ((stringp message)
+    (format "%S" message))
+   (t message)))
+
 (defmacro with-tramp-dbus-call-method
   (vec synchronous bus service path interface method &rest args)
   "Apply a D-Bus call on bus BUS.
@@ -464,7 +479,7 @@
 	 result)
      (tramp-message ,vec 6 "%s %s" func args)
      (setq result (apply func args))
-     (tramp-message ,vec 6 "\n%s" result)
+     (tramp-message ,vec 6 "%s" (tramp-gvfs-stringify-dbus-message result))
      result))
 
 (put 'with-tramp-dbus-call-method 'lisp-indent-function 2)
@@ -478,7 +493,7 @@
   `(let ((fuse-file-name  (regexp-quote (tramp-gvfs-fuse-file-name ,filename)))
 	 elt)
      (condition-case err
-	 (apply ,handler (list ,@args))
+	 (funcall ,handler ,@args)
        (error
 	(setq elt (cdr err))
 	(while elt
@@ -510,25 +525,56 @@
 ;; File name primitives.
 
 (defun tramp-gvfs-handle-copy-file
-  (filename newname &optional ok-if-already-exists keep-date preserve-uid-gid)
+  (filename newname &optional ok-if-already-exists keep-date
+	    preserve-uid-gid preserve-selinux-context)
   "Like `copy-file' for Tramp files."
-  (copy-file
-   (if (tramp-gvfs-file-name-p filename)
-       (tramp-gvfs-fuse-file-name filename)
-     filename)
-   (if (tramp-gvfs-file-name-p newname)
-       (tramp-gvfs-fuse-file-name newname)
-     newname)
-   ok-if-already-exists keep-date preserve-uid-gid))
+  (with-parsed-tramp-file-name
+      (if (tramp-tramp-file-p filename) filename newname) nil
+    (with-progress-reporter
+	v 0 (format "Copying %s to %s" filename newname)
+      (condition-case err
+	  (let ((args
+		 (list
+		  (if (tramp-gvfs-file-name-p filename)
+		      (tramp-gvfs-fuse-file-name filename)
+		    filename)
+		  (if (tramp-gvfs-file-name-p newname)
+		      (tramp-gvfs-fuse-file-name newname)
+		    newname)
+		  ok-if-already-exists keep-date preserve-uid-gid)))
+	    (when preserve-selinux-context
+	      (setq args (append args (list preserve-selinux-context))))
+	    (apply 'copy-file args))
+
+	;; Error case.  Let's try it with the GVFS utilities.
+	(error
+	 (tramp-message v 4 "`copy-file' failed, trying `gvfs-copy'")
+	 (unless
+	     (zerop
+	      (let ((args
+		     (append (if (or keep-date preserve-uid-gid)
+				 (list "--preserve")
+			       nil)
+			     (list
+			      (tramp-gvfs-url-file-name filename)
+			      (tramp-gvfs-url-file-name newname)))))
+		(apply 'tramp-gvfs-send-command v "gvfs-copy" args)))
+	   ;; Propagate the error.
+	   (tramp-error v (car err) "%s" (cdr err)))))))
+
+  (when (file-remote-p newname)
+    (with-parsed-tramp-file-name newname nil
+      (tramp-flush-file-property v (file-name-directory localname))
+      (tramp-flush-file-property v localname))))
 
 (defun tramp-gvfs-handle-delete-directory (directory &optional recursive)
   "Like `delete-directory' for Tramp files."
   (tramp-compat-delete-directory
    (tramp-gvfs-fuse-file-name directory) recursive))
 
-(defun tramp-gvfs-handle-delete-file (filename)
+(defun tramp-gvfs-handle-delete-file (filename &optional trash)
   "Like `delete-file' for Tramp files."
-  (delete-file (tramp-gvfs-fuse-file-name filename)))
+  (tramp-compat-delete-file (tramp-gvfs-fuse-file-name filename) trash))
 
 (defun tramp-gvfs-handle-directory-files
   (directory &optional full match nosort)
@@ -565,6 +611,14 @@
       (tramp-run-real-handler 'expand-file-name (list name nil))
     ;; Dissect NAME.
     (with-parsed-tramp-file-name name nil
+      ;; If there is a default location, expand tilde.
+      (when (string-match "\\`\\(~\\)\\(/\\|\\'\\)" localname)
+	(save-match-data
+	  (tramp-gvfs-maybe-open-connection (vector method user host "/")))
+	(setq localname
+	      (replace-match
+	       (tramp-get-file-property  v "/" "default-location" "~")
+	       nil t localname 1)))
       ;; Tilde expansion is not possible.
       (when (string-match "\\`\\(~[^/]*\\)\\(.*\\)\\'" localname)
 	(tramp-error
@@ -620,6 +674,11 @@
   "Like `file-readable-p' for Tramp files."
   (file-readable-p (tramp-gvfs-fuse-file-name filename)))
 
+(defun tramp-gvfs-handle-file-selinux-context (filename)
+  "Like `file-selinux-context' for Tramp files."
+  (tramp-compat-funcall
+   'file-selinux-context (tramp-gvfs-fuse-file-name filename)))
+
 (defun tramp-gvfs-handle-file-writable-p (filename)
   "Like `file-writable-p' for Tramp files."
   (file-writable-p (tramp-gvfs-fuse-file-name filename)))
@@ -645,19 +704,20 @@
 
 (defun tramp-gvfs-handle-make-directory (dir &optional parents)
   "Like `make-directory' for Tramp files."
-  (condition-case err
-      (with-tramp-gvfs-error-message dir 'make-directory
-	(tramp-gvfs-fuse-file-name dir) parents)
-    ;; Error case.  Let's try it with the GVFS utilities.
-    (error
-     (with-parsed-tramp-file-name dir nil
+  (with-parsed-tramp-file-name dir nil
+    (condition-case err
+	(with-tramp-gvfs-error-message dir 'make-directory
+	  (tramp-gvfs-fuse-file-name dir) parents)
+
+      ;; Error case.  Let's try it with the GVFS utilities.
+      (error
        (tramp-message v 4 "`make-directory' failed, trying `gvfs-mkdir'")
        (unless
 	   (zerop
-	    (tramp-local-call-process
-	     "gvfs-mkdir" nil (tramp-get-buffer v) nil
-	     (tramp-gvfs-url-file-name dir)))
-	 (signal (car err) (cdr err)))))))
+	    (tramp-gvfs-send-command
+	     v "gvfs-mkdir" (tramp-gvfs-url-file-name dir)))
+	 ;; Propagate the error.
+	 (tramp-error v (car err) "%s" (cdr err)))))))
 
 (defun tramp-gvfs-handle-process-file
   (program &optional infile destination display &rest args)
@@ -668,20 +728,52 @@
 (defun tramp-gvfs-handle-rename-file
   (filename newname &optional ok-if-already-exists)
   "Like `rename-file' for Tramp files."
-  (rename-file
-   (if (tramp-gvfs-file-name-p filename)
-       (tramp-gvfs-fuse-file-name filename)
-     filename)
-   (if (tramp-gvfs-file-name-p newname)
-       (tramp-gvfs-fuse-file-name newname)
-     newname)
-   ok-if-already-exists))
+  (with-parsed-tramp-file-name
+      (if (tramp-tramp-file-p filename) filename newname) nil
+    (with-progress-reporter
+	v 0 (format "Renaming %s to %s" filename newname)
+      (condition-case err
+	  (rename-file
+	   (if (tramp-gvfs-file-name-p filename)
+	       (tramp-gvfs-fuse-file-name filename)
+	     filename)
+	   (if (tramp-gvfs-file-name-p newname)
+	       (tramp-gvfs-fuse-file-name newname)
+	     newname)
+	   ok-if-already-exists)
+
+	;; Error case.  Let's try it with the GVFS utilities.
+	(error
+	 (tramp-message v 4 "`rename-file' failed, trying `gvfs-move'")
+	 (unless
+	     (zerop
+	      (tramp-gvfs-send-command
+	       v "gvfs-move"
+	       (tramp-gvfs-url-file-name filename)
+	       (tramp-gvfs-url-file-name newname)))
+	   ;; Propagate the error.
+	   (tramp-error v (car err) "%s" (cdr err)))))))
+
+  (when (file-remote-p filename)
+    (with-parsed-tramp-file-name filename nil
+      (tramp-flush-file-property v (file-name-directory localname))
+      (tramp-flush-file-property v localname)))
+
+  (when (file-remote-p newname)
+    (with-parsed-tramp-file-name newname nil
+      (tramp-flush-file-property v (file-name-directory localname))
+      (tramp-flush-file-property v localname))))
 
 (defun tramp-gvfs-handle-set-file-modes (filename mode)
   "Like `set-file-modes' for Tramp files."
   (with-tramp-gvfs-error-message filename 'set-file-modes
     (tramp-gvfs-fuse-file-name filename) mode))
 
+(defun tramp-gvfs-handle-set-file-selinux-context (filename context)
+  "Like `set-file-selinux-context' for Tramp files."
+  (with-tramp-gvfs-error-message filename 'set-file-selinux-context
+    (tramp-gvfs-fuse-file-name filename) context))
+
 (defun tramp-gvfs-handle-set-visited-file-modtime (&optional time-list)
   "Like `set-visited-file-modtime' for Tramp files."
   (let ((buffer-file-name (tramp-gvfs-fuse-file-name (buffer-file-name))))
@@ -713,19 +805,16 @@
 	  start end (tramp-gvfs-fuse-file-name filename)
 	  append visit lockname confirm)
 
-      ;; Error case.  Let's try it with the GVFS utilities.
+      ;; Error case.  Let's try rename.
       (error
        (let ((tmpfile (tramp-compat-make-temp-file filename)))
-	 (tramp-message v 4 "`write-region' failed, trying `gvfs-save'")
+	 (tramp-message v 4 "`write-region' failed, trying `rename-file'")
 	 (write-region start end tmpfile)
-	 (unwind-protect
-	     (unless
-		 (zerop
-		  (tramp-local-call-process
-		   "gvfs-save" tmpfile (tramp-get-buffer v) nil
-		   (tramp-gvfs-url-file-name filename)))
-	       (signal (car err) (cdr err)))
-	   (delete-file tmpfile)))))
+	 (condition-case nil
+	     (rename-file tmpfile filename)
+	   (error
+	    (delete-file tmpfile)
+	    (tramp-error v (car err) "%s" (cdr err)))))))
 
     ;; Set file modification time.
     (when (or (eq visit t) (stringp visit))
@@ -741,16 +830,20 @@
 
 (defun tramp-gvfs-url-file-name (filename)
   "Return FILENAME in URL syntax."
-  (url-recreate-url
-   (if (tramp-tramp-file-p filename)
-       (with-parsed-tramp-file-name (file-truename filename) nil
-	 (when (string-match tramp-user-with-domain-regexp user)
-	   (setq user
-		 (concat (match-string 2 user) ";"  (match-string 2 user))))
-	 (url-parse-make-urlobj
-	  method user nil
-	  (tramp-file-name-real-host v) (tramp-file-name-port v) localname))
-     (url-parse-make-urlobj "file" nil nil nil nil (file-truename filename)))))
+  ;; "/" must NOT be hexlified.
+  (let ((url-unreserved-chars (append '(?/) url-unreserved-chars)))
+    (url-recreate-url
+     (if (tramp-tramp-file-p filename)
+	 (with-parsed-tramp-file-name (file-truename filename) nil
+	   (when (string-match tramp-user-with-domain-regexp user)
+	     (setq user
+		   (concat (match-string 2 user) ";"  (match-string 2 user))))
+	   (url-parse-make-urlobj
+	    method user nil
+	    (tramp-file-name-real-host v) (tramp-file-name-port v)
+	    (url-hexify-string localname)))
+       (url-parse-make-urlobj
+	"file" nil nil nil nil (url-hexify-string (file-truename filename)))))))
 
 (defun tramp-gvfs-object-path (filename)
   "Create a D-Bus object path from FILENAME."
@@ -765,15 +858,19 @@
   "Return FUSE file name, which is directly accessible."
   (with-parsed-tramp-file-name (expand-file-name filename) nil
     (tramp-gvfs-maybe-open-connection v)
-    (let ((fuse-mountpoint
+    (let ((prefix (tramp-get-file-property v "/" "prefix" ""))
+	  (fuse-mountpoint
 	   (tramp-get-file-property v "/" "fuse-mountpoint" nil)))
       (unless fuse-mountpoint
 	(tramp-error
 	 v 'file-error "There is no FUSE mount point for `%s'" filename))
-      ;; We must remove the share from the local name.
-      (when (and (string-equal "smb" method) (string-match "/[^/]+" localname))
+      ;; We must hide the prefix, if any.
+      (when (string-match (concat "^" (regexp-quote prefix)) localname)
 	(setq localname (replace-match "" t t localname)))
-      (concat tramp-gvfs-mount-point fuse-mountpoint localname))))
+      (tramp-message
+       v 10 "remote file `%s' is local file `%s'"
+       filename (concat fuse-mountpoint localname))
+      (concat fuse-mountpoint localname))))
 
 (defun tramp-bluez-address (device)
   "Return bluetooth device address from a given bluetooth DEVICE name."
@@ -857,59 +954,79 @@
 	    ;; there is only the question whether to accept an unknown
 	    ;; host signature.
 	    (with-temp-buffer
-	      (insert message)
-	      (pop-to-buffer (current-buffer))
-	      (setq choice (if (yes-or-no-p (concat (car choices) " ")) 0 1))
-	      (tramp-message v 6 "%d" choice))
+	      ;; Preserve message for `progress-reporter'.
+	      (with-temp-message ""
+		(insert message)
+		(pop-to-buffer (current-buffer))
+		(setq choice (if (yes-or-no-p (concat (car choices) " ")) 0 1))
+		(tramp-message v 6 "%d" choice)))
 
-	    ;; When the choice is "no", we set an empty
-	    ;; fuse-mountpoint in order to leave the timeout.
+	    ;; When the choice is "no", we set a dummy fuse-mountpoint
+	    ;; in order to leave the timeout.
 	    (unless (zerop choice)
-	      (tramp-set-file-property v "/" "fuse-mountpoint" ""))
+	      (tramp-set-file-property v "/" "fuse-mountpoint" "/"))
 
 	    (list
 	     t ;; handled.
 	     nil ;; no abort of D-Bus.
 	     choice))
 
-	  ;; When QUIT is raised, we shall return this information to D-Bus.
-	  (quit (list nil t 0))))))
+	;; When QUIT is raised, we shall return this information to D-Bus.
+	(quit (list nil t 0))))))
 
 (defun tramp-gvfs-handler-mounted-unmounted (mount-info)
   "Signal handler for the \"org.gtk.vfs.MountTracker.mounted\" and
 \"org.gtk.vfs.MountTracker.unmounted\" signals."
   (ignore-errors
-    (let* ((signal-name (dbus-event-member-name last-input-event))
-	   (mount-spec (cadar (last mount-info)))
-	   (method (dbus-byte-array-to-string (cadr (assoc "type" mount-spec))))
-	   (user (dbus-byte-array-to-string (cadr (assoc "user" mount-spec))))
-	   (domain (dbus-byte-array-to-string
-		    (cadr (assoc "domain" mount-spec))))
-	   (host (dbus-byte-array-to-string
-		  (cadr (or (assoc "host" mount-spec)
-			    (assoc "server" mount-spec)))))
-	   (port (dbus-byte-array-to-string (cadr (assoc "port" mount-spec))))
-	   (ssl (dbus-byte-array-to-string (cadr (assoc "ssl" mount-spec)))))
-      (when (string-match "^smb" method)
-	(setq method "smb"))
-      (when (string-equal "obex" method)
-	(setq host (tramp-bluez-device host)))
-      (when (and (string-equal "dav" method) (string-equal "true" ssl))
-	(setq method "davs"))
-      (unless (zerop (length domain))
-	(setq user (concat user tramp-prefix-domain-format domain)))
-      (unless (zerop (length port))
-	(setq host (concat host tramp-prefix-port-format port)))
-      (with-parsed-tramp-file-name
-	  (tramp-make-tramp-file-name method user host "") nil
-	(tramp-message v 6 "%s %s" signal-name mount-info)
-	(tramp-set-file-property v "/" "list-mounts" 'undef)
-	(if (string-equal signal-name "unmounted")
-	    (tramp-set-file-property v "/" "fuse-mountpoint" nil)
-	  (tramp-set-file-property
-	   v "/" "fuse-mountpoint"
-	   (file-name-nondirectory
-	    (dbus-byte-array-to-string (car (last mount-info 2))))))))))
+    (let ((signal-name (dbus-event-member-name last-input-event))
+	  (elt mount-info))
+      ;; Jump over the first elements of the mount info. Since there
+      ;; were changes in the antries, we cannot access dedicated
+      ;; elements.
+      (while (stringp (car elt)) (setq elt (cdr elt)))
+      (let* ((fuse-mountpoint (dbus-byte-array-to-string (cadr elt)))
+	     (mount-spec (caddr elt))
+	     (default-location (dbus-byte-array-to-string (cadddr elt)))
+	     (method (dbus-byte-array-to-string
+		      (cadr (assoc "type" (cadr mount-spec)))))
+	     (user (dbus-byte-array-to-string
+		    (cadr (assoc "user" (cadr mount-spec)))))
+	     (domain (dbus-byte-array-to-string
+		      (cadr (assoc "domain" (cadr mount-spec)))))
+	     (host (dbus-byte-array-to-string
+		    (cadr (or (assoc "host" (cadr mount-spec))
+			      (assoc "server" (cadr mount-spec))))))
+	     (port (dbus-byte-array-to-string
+		    (cadr (assoc "port" (cadr mount-spec)))))
+	     (ssl (dbus-byte-array-to-string
+		   (cadr (assoc "ssl" (cadr mount-spec)))))
+	     (prefix (concat (dbus-byte-array-to-string (car mount-spec))
+			     (dbus-byte-array-to-string
+			      (cadr (assoc "share" (cadr mount-spec)))))))
+	(when (string-match "^smb" method)
+	  (setq method "smb"))
+	(when (string-equal "obex" method)
+	  (setq host (tramp-bluez-device host)))
+	(when (and (string-equal "dav" method) (string-equal "true" ssl))
+	  (setq method "davs"))
+	(unless (zerop (length domain))
+	  (setq user (concat user tramp-prefix-domain-format domain)))
+	(unless (zerop (length port))
+	  (setq host (concat host tramp-prefix-port-format port)))
+	(with-parsed-tramp-file-name
+	    (tramp-make-tramp-file-name method user host "") nil
+	  (tramp-message
+	   v 6 "%s %s"
+	   signal-name (tramp-gvfs-stringify-dbus-message mount-info))
+	  (tramp-set-file-property v "/" "list-mounts" 'undef)
+	  (if (string-equal signal-name "unmounted")
+	      (tramp-set-file-property v "/" "fuse-mountpoint" nil)
+	    ;; Set prefix, mountpoint and location.
+	    (unless (string-equal prefix "/")
+	      (tramp-set-file-property v "/" "prefix" prefix))
+	    (tramp-set-file-property v "/" "fuse-mountpoint" fuse-mountpoint)
+	    (tramp-set-file-property
+	     v "/" "default-location" default-location)))))))
 
 (dbus-register-signal
  :session nil tramp-gvfs-path-mounttracker
@@ -923,47 +1040,63 @@
 
 (defun tramp-gvfs-connection-mounted-p (vec)
   "Check, whether the location is already mounted."
-  (catch 'mounted
-    (dolist
-	(elt
-	 (with-file-property vec "/" "list-mounts"
-	   (with-tramp-dbus-call-method vec t
-	     :session tramp-gvfs-service-daemon tramp-gvfs-path-mounttracker
-	     tramp-gvfs-interface-mounttracker "listMounts"))
-	 nil)
-      (let* ((mount-spec (cadar (last elt)))
-	     (method (dbus-byte-array-to-string
-		      (cadr (assoc "type" mount-spec))))
-	     (user (dbus-byte-array-to-string
-		    (cadr (assoc "user" mount-spec))))
-	     (domain (dbus-byte-array-to-string
-		      (cadr (assoc "domain" mount-spec))))
-	     (host (dbus-byte-array-to-string
-		    (cadr (or (assoc "host" mount-spec)
-			      (assoc "server" mount-spec)))))
-	     (port (dbus-byte-array-to-string (cadr (assoc "port" mount-spec))))
-	     (ssl (dbus-byte-array-to-string (cadr (assoc "ssl" mount-spec)))))
-	(when (string-match "^smb" method)
-	  (setq method "smb"))
-	(when (string-equal "obex" method)
-	  (setq host (tramp-bluez-device host)))
-	(when (and (string-equal "dav" method) (string-equal "true" ssl))
-	  (setq method "davs"))
-	(when (and (string-equal "synce" method) (zerop (length user)))
-	  (setq user (or (tramp-file-name-user vec) "")))
-	(unless (zerop (length domain))
-	  (setq user (concat user tramp-prefix-domain-format domain)))
-	(unless (zerop (length port))
-	  (setq host (concat host tramp-prefix-port-format port)))
-	(when (and
-	       (string-equal method (tramp-file-name-method vec))
-	       (string-equal user (or (tramp-file-name-user vec) ""))
-	       (string-equal host (tramp-file-name-host vec)))
-	  (tramp-set-file-property
-	   vec "/" "fuse-mountpoint"
-	   (file-name-nondirectory
-	    (dbus-byte-array-to-string (car (last elt 2)))))
-	  (throw 'mounted t))))))
+  (or
+   (tramp-get-file-property vec "/" "fuse-mountpoint" nil)
+   (catch 'mounted
+     (dolist
+	 (elt
+	  (with-file-property vec "/" "list-mounts"
+	    (with-tramp-dbus-call-method vec t
+	      :session tramp-gvfs-service-daemon tramp-gvfs-path-mounttracker
+	      tramp-gvfs-interface-mounttracker "listMounts"))
+	  nil)
+       ;; Jump over the first elements of the mount info. Since there
+       ;; were changes in the antries, we cannot access dedicated
+       ;; elements.
+       (while (stringp (car elt)) (setq elt (cdr elt)))
+       (let* ((fuse-mountpoint (dbus-byte-array-to-string (cadr elt)))
+	      (mount-spec (caddr elt))
+	      (default-location (dbus-byte-array-to-string (cadddr elt)))
+	      (method (dbus-byte-array-to-string
+		       (cadr (assoc "type" (cadr mount-spec)))))
+	      (user (dbus-byte-array-to-string
+		     (cadr (assoc "user" (cadr mount-spec)))))
+	      (domain (dbus-byte-array-to-string
+		       (cadr (assoc "domain" (cadr mount-spec)))))
+	      (host (dbus-byte-array-to-string
+		     (cadr (or (assoc "host" (cadr mount-spec))
+			       (assoc "server" (cadr mount-spec))))))
+	      (port (dbus-byte-array-to-string
+		     (cadr (assoc "port" (cadr mount-spec)))))
+	      (ssl (dbus-byte-array-to-string
+		    (cadr (assoc "ssl" (cadr mount-spec)))))
+	      (prefix (concat (dbus-byte-array-to-string (car mount-spec))
+			      (dbus-byte-array-to-string
+			       (cadr (assoc "share" (cadr mount-spec)))))))
+	 (when (string-match "^smb" method)
+	   (setq method "smb"))
+	 (when (string-equal "obex" method)
+	   (setq host (tramp-bluez-device host)))
+	 (when (and (string-equal "dav" method) (string-equal "true" ssl))
+	   (setq method "davs"))
+	 (when (and (string-equal "synce" method) (zerop (length user)))
+	   (setq user (or (tramp-file-name-user vec) "")))
+	 (unless (zerop (length domain))
+	   (setq user (concat user tramp-prefix-domain-format domain)))
+	 (unless (zerop (length port))
+	   (setq host (concat host tramp-prefix-port-format port)))
+	 (when (and
+		(string-equal method (tramp-file-name-method vec))
+		(string-equal user (or (tramp-file-name-user vec) ""))
+		(string-equal host (tramp-file-name-host vec))
+		(string-match (concat "^" (regexp-quote prefix))
+			      (tramp-file-name-localname vec)))
+	   ;; Set prefix, mountpoint and location.
+	   (unless (string-equal prefix "/")
+	     (tramp-set-file-property vec "/" "prefix" prefix))
+	   (tramp-set-file-property vec "/" "fuse-mountpoint" fuse-mountpoint)
+	   (tramp-set-file-property vec "/" "default-location" default-location)
+	   (throw 'mounted t)))))))
 
 (defun tramp-gvfs-mount-spec (vec)
   "Return a mount-spec for \"org.gtk.vfs.MountTracker.mountLocation\"."
@@ -974,7 +1107,8 @@
 	 (port (tramp-file-name-port vec))
 	 (localname (tramp-file-name-localname vec))
 	 (ssl (if (string-match "^davs" method) "true" "false"))
-	 (mount-spec `(:array)))
+	 (mount-spec '(:array))
+	 (mount-pref "/"))
 
     (setq
      mount-spec
@@ -1017,8 +1151,12 @@
        `(:struct "port" ,(dbus-string-to-byte-array (number-to-string port)))
        'append))
 
+    (when (and (string-match "^dav" method)
+	       (string-match "^/?[^/]+" localname))
+      (setq mount-pref (match-string 0 localname)))
+
     ;; Return.
-    mount-spec))
+    `(:struct ,(dbus-string-to-byte-array mount-pref) ,mount-spec)))
 
 
 ;; Connection functions
@@ -1050,65 +1188,73 @@
 	    (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"
+	  (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)))
+
+	;; If `tramp-gvfs-handler-askquestion' has returned "No", it
+	;; is marked with the fuse-mountpoint "/".  We shall react.
+	(when (string-equal
+	       (tramp-get-file-property vec "/" "fuse-mountpoint" "") "/")
+	  (tramp-error vec 'file-error "FUSE mount denied"))
 
-      ;; 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)
+	;; 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)))))
+(defun tramp-gvfs-send-command (vec command &rest args)
+  "Send the COMMAND with its ARGS to connection VEC.
+COMMAND is usually a command from the gvfs-* utilities.
+`call-process' is applied, and its return code is returned."
+  (let (result)
+    (with-current-buffer (tramp-get-buffer vec)
+      (erase-buffer)
+      (tramp-message vec 6 "%s %s" command (mapconcat 'identity args " "))
+      (setq result (apply 'tramp-local-call-process command nil t nil args))
+      (tramp-message vec 6 "%s" (buffer-string))
+      result)))
 
 
 ;; D-Bus BLUEZ functions.
--- a/lisp/net/tramp-imap.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/net/tramp-imap.el	Fri Aug 27 23:06:02 2010 +0900
@@ -63,6 +63,7 @@
 (autoload 'epg-context-set-progress-callback "epg")
 (autoload 'epg-decrypt-string "epg")
 (autoload 'epg-encrypt-string "epg")
+(autoload 'epg-make-context "epg")
 (autoload 'imap-hash-get "imap-hash")
 (autoload 'imap-hash-make "imap-hash")
 (autoload 'imap-hash-map "imap-hash")
@@ -124,7 +125,6 @@
     (file-executable-p . tramp-imap-handle-file-executable-p)
     (file-exists-p . tramp-imap-handle-file-exists-p)
     (file-local-copy . tramp-imap-handle-file-local-copy)
-    (file-remote-p . tramp-handle-file-remote-p)
     (file-modes . tramp-handle-file-modes)
     (file-name-all-completions . tramp-imap-handle-file-name-all-completions)
     (file-name-as-directory . tramp-handle-file-name-as-directory)
@@ -136,6 +136,8 @@
     (file-ownership-preserved-p . ignore)
     (file-readable-p . tramp-imap-handle-file-readable-p)
     (file-regular-p . tramp-handle-file-regular-p)
+    (file-remote-p . tramp-handle-file-remote-p)
+    ;; `file-selinux-context' performed by default handler.
     (file-symlink-p . tramp-handle-file-symlink-p)
     ;; `file-truename' performed by default handler
     (file-writable-p . tramp-imap-handle-file-writable-p)
@@ -150,6 +152,7 @@
     (make-symbolic-link . ignore)
     (rename-file . tramp-imap-handle-rename-file)
     (set-file-modes . ignore)
+    ;; `set-file-selinux-context' performed by default handler.
     (set-file-times . ignore) ;; tramp-imap-handle-set-file-times)
     (set-visited-file-modtime . ignore)
     (shell-command . ignore)
@@ -168,7 +171,7 @@
 (defgroup tramp-imap nil
   "Tramp over IMAP configuration."
   :version "23.2"
-  :group 'applications)
+  :group 'tramp)
 
 (defcustom tramp-imap-subject-marker "tramp-imap-subject-marker"
   "The subject marker that Tramp-IMAP will use."
@@ -200,7 +203,8 @@
 	     (cons 'tramp-imap-file-name-p 'tramp-imap-file-name-handler))
 
 (defun tramp-imap-handle-copy-file
-  (filename newname &optional ok-if-already-exists keep-date preserve-uid-gid)
+  (filename newname &optional ok-if-already-exists keep-date
+	    preserve-uid-gid preserve-selinux-context)
   "Like `copy-file' for Tramp files."
   (tramp-imap-do-copy-or-rename-file
    'copy filename newname ok-if-already-exists keep-date preserve-uid-gid))
@@ -237,35 +241,33 @@
 	(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)))
+	;; 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)))))
 
-    (with-parsed-tramp-file-name (if t1 filename newname) nil
-      (tramp-message v 0 "Transferring %s to %s...done" filename newname))
-
-    (when (eq op 'rename)
-      (delete-file filename))))
+    (when (eq op 'rename) (delete-file filename))))
 
 ;; TODO: revise this much
 (defun tramp-imap-handle-expand-file-name (name &optional dir)
@@ -501,17 +503,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."
@@ -550,7 +551,7 @@
   ;; (file-exists-p (file-name-directory filename)))
   (file-directory-p (file-name-directory filename)))
 
-(defun tramp-imap-handle-delete-file (filename)
+(defun tramp-imap-handle-delete-file (filename &optional trash)
   "Like `delete-file' for Tramp files."
   (cond
    ((not (file-exists-p filename)) nil)
@@ -584,12 +585,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-smb.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/net/tramp-smb.el	Fri Aug 27 23:06:02 2010 +0900
@@ -164,7 +164,6 @@
     (file-executable-p . tramp-smb-handle-file-exists-p)
     (file-exists-p . tramp-smb-handle-file-exists-p)
     (file-local-copy . tramp-smb-handle-file-local-copy)
-    (file-remote-p . tramp-handle-file-remote-p)
     (file-modes . tramp-handle-file-modes)
     (file-name-all-completions . tramp-smb-handle-file-name-all-completions)
     (file-name-as-directory . tramp-handle-file-name-as-directory)
@@ -176,6 +175,8 @@
     (file-ownership-preserved-p . ignore)
     (file-readable-p . tramp-smb-handle-file-exists-p)
     (file-regular-p . tramp-handle-file-regular-p)
+    (file-remote-p . tramp-handle-file-remote-p)
+    ;; `file-selinux-context' performed by default handler.
     (file-symlink-p . tramp-handle-file-symlink-p)
     ;; `file-truename' performed by default handler.
     (file-writable-p . tramp-smb-handle-file-writable-p)
@@ -190,6 +191,7 @@
     (make-symbolic-link . tramp-smb-handle-make-symbolic-link)
     (rename-file . tramp-smb-handle-rename-file)
     (set-file-modes . tramp-smb-handle-set-file-modes)
+    ;; `set-file-selinux-context' performed by default handler.
     (set-file-times . ignore)
     (set-visited-file-modtime . ignore)
     (shell-command . ignore)
@@ -325,47 +327,48 @@
 	 'copy-directory (list dirname newname keep-date parents)))))))
 
 (defun tramp-smb-handle-copy-file
-  (filename newname &optional ok-if-already-exists keep-date preserve-uid-gid)
+  (filename newname &optional ok-if-already-exists keep-date
+	    preserve-uid-gid preserve-selinux-context)
   "Like `copy-file' for Tramp files.
 KEEP-DATE is not handled in case NEWNAME resides on an SMB server.
 PRESERVE-UID-GID is completely ignored."
   (setq filename (expand-file-name filename)
 	newname (expand-file-name newname))
+  (with-progress-reporter
+      (tramp-dissect-file-name (if (file-remote-p filename) filename newname))
+      0 (format "Copying %s to %s" filename newname)
 
-  (let ((tmpfile (file-local-copy filename)))
+    (let ((tmpfile (file-local-copy filename)))
 
-    (if tmpfile
-	;; Remote filename.
-	(condition-case err
-	    (rename-file tmpfile newname ok-if-already-exists)
-	  ((error quit)
-	   (delete-file tmpfile)
-	   (signal (car err) (cdr err))))
-
-      ;; Remote newname.
-      (when (file-directory-p newname)
-	(setq newname (expand-file-name
-		       (file-name-nondirectory filename) newname)))
+      (if tmpfile
+	  ;; Remote filename.
+	  (condition-case err
+	      (rename-file tmpfile newname ok-if-already-exists)
+	    ((error quit)
+	     (delete-file tmpfile)
+	     (signal (car err) (cdr err))))
 
-      (with-parsed-tramp-file-name newname nil
-	(when (and (not ok-if-already-exists)
-		   (file-exists-p newname))
-	  (tramp-error v 'file-already-exists newname))
+	;; Remote newname.
+	(when (file-directory-p newname)
+	  (setq newname
+		(expand-file-name (file-name-nondirectory filename) newname)))
+
+	(with-parsed-tramp-file-name newname nil
+	  (when (and (not ok-if-already-exists)
+		     (file-exists-p newname))
+	    (tramp-error v 'file-already-exists newname))
 
-	;; We must also flush the cache of the directory, because
-	;; `file-attributes' reads the values from there.
-	(tramp-flush-file-property v (file-name-directory localname))
-	(tramp-flush-file-property v localname)
-	(unless (tramp-smb-get-share v)
-	  (tramp-error
-	   v 'file-error "Target `%s' must contain a share name" newname))
-	(tramp-message v 0 "Copying file %s to file %s..." filename newname)
-	(if (tramp-smb-send-command
-	     v (format "put \"%s\" \"%s\""
-		       filename (tramp-smb-get-localname v)))
-	    (tramp-message
-	     v 0 "Copying file %s to file %s...done" filename newname)
-	  (tramp-error v 'file-error "Cannot copy `%s'" filename)))))
+	  ;; We must also flush the cache of the directory, because
+	  ;; `file-attributes' reads the values from there.
+	  (tramp-flush-file-property v (file-name-directory localname))
+	  (tramp-flush-file-property v localname)
+	  (unless (tramp-smb-get-share v)
+	    (tramp-error
+	     v 'file-error "Target `%s' must contain a share name" newname))
+	  (unless (tramp-smb-send-command
+		   v (format "put \"%s\" \"%s\""
+			     filename (tramp-smb-get-localname v)))
+	    (tramp-error v 'file-error "Cannot copy `%s'" filename))))))
 
   ;; KEEP-DATE handling.
   (when keep-date (set-file-times newname (nth 5 (file-attributes filename)))))
@@ -401,7 +404,7 @@
 	  (tramp-error
 	   v 'file-error "%s `%s'" (match-string 0) directory))))))
 
-(defun tramp-smb-handle-delete-file (filename)
+(defun tramp-smb-handle-delete-file (filename &optional trash)
   "Like `delete-file' for Tramp files."
   (setq filename (expand-file-name filename))
   (when (file-exists-p filename)
@@ -602,15 +605,15 @@
        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)
-      (if (tramp-smb-send-command
-	   v (format "get \"%s\" \"%s\"" (tramp-smb-get-localname v) tmpfile))
-	  (tramp-message
-	   v 4 "Fetching %s to tmp file %s...done" filename tmpfile)
-	;; Oops, an error.  We shall cleanup.
-	(delete-file tmpfile)
-	(tramp-error
-	 v 'file-error "Cannot make local copy of file `%s'" filename))
+      (with-progress-reporter
+	  v 3 (format "Fetching %s to tmp file %s" filename tmpfile)
+	(unless (tramp-smb-send-command
+		 v (format "get \"%s\" \"%s\""
+			   (tramp-smb-get-localname v) tmpfile))
+	  ;; Oops, an error.  We shall cleanup.
+	  (delete-file tmpfile)
+	  (tramp-error
+	   v 'file-error "Cannot make local copy of file `%s'" filename)))
       tmpfile)))
 
 ;; This function should return "foo/" for directories and "bar" for
@@ -847,38 +850,39 @@
   "Like `rename-file' for Tramp files."
   (setq filename (expand-file-name filename)
 	newname (expand-file-name newname))
+  (with-progress-reporter
+      (tramp-dissect-file-name (if (file-remote-p filename) filename newname))
+      0 (format "Renaming %s to %s" filename newname)
 
-  (let ((tmpfile (file-local-copy filename)))
+    (let ((tmpfile (file-local-copy filename)))
 
-    (if tmpfile
-	;; Remote filename.
-	(condition-case err
-	    (rename-file tmpfile newname ok-if-already-exists)
-	  ((error quit)
-	   (delete-file tmpfile)
-	   (signal (car err) (cdr err))))
-
-      ;; Remote newname.
-      (when (file-directory-p newname)
-	(setq newname (expand-file-name
-		      (file-name-nondirectory filename) newname)))
+      (if tmpfile
+	  ;; Remote filename.
+	  (condition-case err
+	      (rename-file tmpfile newname ok-if-already-exists)
+	    ((error quit)
+	     (delete-file tmpfile)
+	     (signal (car err) (cdr err))))
 
-      (with-parsed-tramp-file-name newname nil
-	(when (and (not ok-if-already-exists)
-		   (file-exists-p newname))
-	  (tramp-error v 'file-already-exists newname))
-	;; We must also flush the cache of the directory, because
-	;; `file-attributes' reads the values from there.
-	(tramp-flush-file-property v (file-name-directory localname))
-	(tramp-flush-file-property v localname)
-	(tramp-message v 0 "Copying file %s to file %s..." filename newname)
-	(if (tramp-smb-send-command
-	     v (format "put %s \"%s\"" filename (tramp-smb-get-localname v)))
-	    (tramp-message
-	     v 0 "Copying file %s to file %s...done" filename newname)
-	  (tramp-error v 'file-error "Cannot rename `%s'" filename)))))
+	;; Remote newname.
+	(when (file-directory-p newname)
+	  (setq newname (expand-file-name
+			 (file-name-nondirectory filename) newname)))
 
-  (delete-file filename))
+	(with-parsed-tramp-file-name newname nil
+	  (when (and (not ok-if-already-exists)
+		     (file-exists-p newname))
+	    (tramp-error v 'file-already-exists newname))
+	  ;; We must also flush the cache of the directory, because
+	  ;; `file-attributes' reads the values from there.
+	  (tramp-flush-file-property v (file-name-directory localname))
+	  (tramp-flush-file-property v localname)
+	  (unless (tramp-smb-send-command
+		   v (format "put %s \"%s\""
+			     filename (tramp-smb-get-localname v)))
+	    (tramp-error v 'file-error "Cannot rename `%s'" filename)))))
+
+    (delete-file filename)))
 
 (defun tramp-smb-handle-set-file-modes (filename mode)
   "Like `set-file-modes' for Tramp files."
@@ -935,14 +939,14 @@
 	   (list start end tmpfile append 'no-message lockname confirm)
 	 (list start end tmpfile append 'no-message lockname)))
 
-      (tramp-message v 5 "Writing tmp file %s to file %s..." tmpfile filename)
-      (unwind-protect
-	  (if (tramp-smb-send-command
-	       v (format "put %s \"%s\"" tmpfile (tramp-smb-get-localname v)))
-	      (tramp-message
-	       v 5 "Writing tmp file %s to file %s...done" tmpfile filename)
-	    (tramp-error v 'file-error "Cannot write `%s'" filename))
-	(delete-file tmpfile))
+      (with-progress-reporter
+	  v 3 (format "Moving tmp file %s to %s" tmpfile filename)
+	(unwind-protect
+	    (unless (tramp-smb-send-command
+		     v (format "put %s \"%s\""
+			       tmpfile (tramp-smb-get-localname v)))
+	      (tramp-error v 'file-error "Cannot write `%s'" filename))
+	  (delete-file tmpfile)))
 
       (unless (equal curbuf (current-buffer))
 	(tramp-error
@@ -1299,60 +1303,57 @@
 	    (setq args (append args (list "-s" tramp-smb-conf))))
 
 	  ;; OK, let's go.
-	  (tramp-message
-	   vec 3 "Opening connection for //%s%s/%s..."
-	   (if (not (zerop (length user))) (concat user "@") "")
-	   host (or share ""))
+	  (with-progress-reporter
+	      vec 3
+	      (format "Opening connection for //%s%s/%s"
+		      (if (not (zerop (length user))) (concat user "@") "")
+		      host (or share ""))
 
-	  (let* ((coding-system-for-read nil)
-		 (process-connection-type tramp-process-connection-type)
-		 (p (let ((default-directory
-			    (tramp-compat-temporary-file-directory)))
-		      (apply #'start-process
-			     (tramp-buffer-name vec) (tramp-get-buffer vec)
-			     tramp-smb-program args))))
+	    (let* ((coding-system-for-read nil)
+		   (process-connection-type tramp-process-connection-type)
+		   (p (let ((default-directory
+			      (tramp-compat-temporary-file-directory)))
+			(apply #'start-process
+			       (tramp-buffer-name vec) (tramp-get-buffer vec)
+			       tramp-smb-program args))))
 
-	    (tramp-message
-	     vec 6 "%s" (mapconcat 'identity (process-command p) " "))
-	    (tramp-set-process-query-on-exit-flag p nil)
+	      (tramp-message
+	       vec 6 "%s" (mapconcat 'identity (process-command p) " "))
+	      (tramp-set-process-query-on-exit-flag p nil)
 
-	    ;; Set variables for computing the prompt for reading password.
-	    (setq tramp-current-method tramp-smb-method
-		  tramp-current-user user
-		  tramp-current-host host)
+	      ;; Set variables for computing the prompt for reading password.
+	      (setq tramp-current-method tramp-smb-method
+		    tramp-current-user user
+		    tramp-current-host host)
 
-	    ;; Play login scenario.
-	    (tramp-process-actions
-	     p vec
-	     (if share
-		 tramp-smb-actions-with-share
-	       tramp-smb-actions-without-share))
+	      ;; Play login scenario.
+	      (tramp-process-actions
+	       p vec
+	       (if share
+		   tramp-smb-actions-with-share
+		 tramp-smb-actions-without-share))
 
-	    ;; Check server version.
-	    (with-current-buffer (tramp-get-connection-buffer vec)
-	      (goto-char (point-min))
-	      (search-forward-regexp
-	       "Domain=\\[[^]]*\\] OS=\\[[^]]*\\] Server=\\[[^]]*\\]" nil t)
-	      (let ((smbserver-version (match-string 0)))
-		(unless
-		    (string-equal
-		     smbserver-version
-		     (tramp-get-connection-property
-		      vec "smbserver-version" smbserver-version))
-		  (tramp-flush-directory-property vec "")
-		  (tramp-flush-connection-property vec))
-		(tramp-set-connection-property
-		 vec "smbserver-version" smbserver-version)))
+	      ;; Check server version.
+	      (with-current-buffer (tramp-get-connection-buffer vec)
+		(goto-char (point-min))
+		(search-forward-regexp
+		 "Domain=\\[[^]]*\\] OS=\\[[^]]*\\] Server=\\[[^]]*\\]" nil t)
+		(let ((smbserver-version (match-string 0)))
+		  (unless
+		      (string-equal
+		       smbserver-version
+		       (tramp-get-connection-property
+			vec "smbserver-version" smbserver-version))
+		    (tramp-flush-directory-property vec "")
+		    (tramp-flush-connection-property vec))
+		  (tramp-set-connection-property
+		   vec "smbserver-version" smbserver-version)))
 
-	    ;; Set chunksize.  Otherwise, `tramp-send-string' might
-	    ;; try it itself.
-	    (tramp-set-connection-property p "smb-share" share)
-	    (tramp-set-connection-property p "chunksize" tramp-chunksize)
-
-	    (tramp-message
-	     vec 3 "Opening connection for //%s%s/%s...done"
-	     (if (not (zerop (length user))) (concat user "@") "")
-	     host (or share ""))))))))
+	      ;; Set chunksize.  Otherwise, `tramp-send-string' might
+	      ;; try it itself.
+	      (tramp-set-connection-property p "smb-share" share)
+	      (tramp-set-connection-property
+	       p "chunksize" tramp-chunksize))))))))
 
 ;; We don't use timeouts.  If needed, the caller shall wrap around.
 (defun tramp-smb-wait-for-output (vec)
--- a/lisp/net/tramp-uu.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/net/tramp-uu.el	Fri Aug 27 23:06:02 2010 +0900
@@ -1,7 +1,7 @@
 ;;; tramp-uu.el --- uuencode in Lisp
 
-;; Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007,
-;;   2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+;;   2009, 2010 Free Software Foundation, Inc.
 
 ;; Author: Kai Großjohann <kai.grossjohann@gmx.net>
 ;; Keywords: comm, terminals
--- a/lisp/net/tramp.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/net/tramp.el	Fri Aug 27 23:06:02 2010 +0900
@@ -36,7 +36,7 @@
 ;; Notes:
 ;; -----
 ;;
-;; This package only works for Emacs 21.1 and higher, and for XEmacs 21.4
+;; This package only works for Emacs 22.1 and higher, and for XEmacs 21.4
 ;; and higher.  For XEmacs 21, you need the package `fsf-compat' for
 ;; the `with-timeout' macro.
 ;;
@@ -79,7 +79,7 @@
 	    (when (featurep 'tramp-compat)
 	      (unload-feature 'tramp-compat 'force))))
 
-(require 'format-spec)                  ; from Gnus 5.8, also in tar ball
+(require 'format-spec)
 ;; As long as password.el is not part of (X)Emacs, it shouldn't
 ;; be mandatory
 (if (featurep 'xemacs)
@@ -145,7 +145,7 @@
 	 ;; this would load dbus.el.
 	 (when (and (featurep 'dbusbind)
 		    (condition-case nil
-			(funcall 'dbus-get-unique-name :session)
+			(tramp-compat-funcall 'dbus-get-unique-name :session)
 		      (error nil))
 		    (tramp-compat-process-running-p "gvfs-fuse-daemon"))
 	   'tramp-gvfs)
@@ -176,6 +176,7 @@
 (defgroup tramp nil
   "Edit remote files with a combination of rsh and rcp or similar programs."
   :group 'files
+  :group 'comm
   :version "22.1")
 
 ;; Maybe we need once a real Tramp mode, with key bindings etc.
@@ -199,6 +200,7 @@
  6  sent and received strings
  7  file caching
  8  connection properties
+ 9  test commands
 10  traces (huge)."
   :group 'tramp
   :type 'integer)
@@ -284,10 +286,19 @@
   :group 'tramp
   :type 'string)
 
+(defcustom tramp-inline-compress-start-size 4096
+  "*The minimum size of compressing where inline transfer.
+When inline transfer, compress transfered data of file
+whose size is this value or above (up to `tramp-copy-size-limit').
+If it is nil, no compression at all will be applied."
+  :group 'tramp
+  :type '(choice (const nil) integer))
+
 (defcustom tramp-copy-size-limit 10240
-  "*The maximum file size where inline copying is preferred over an out-of-the-band copy."
+  "*The maximum file size where inline copying is preferred over an out-of-the-band copy.
+If it is nil, inline out-of-the-band copy will be used without a check."
   :group 'tramp
-  :type 'integer)
+  :type '(choice (const nil) integer))
 
 (defcustom tramp-terminal-type "dumb"
   "*Value of TERM environment variable for logging in to remote host.
@@ -322,8 +333,9 @@
 	     (tramp-copy-recursive       t)
 	     (tramp-password-end-of-line nil))
     ("scp"   (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
-					  ("-e" "none")))
+             (tramp-login-args           (("-l" "%u") ("-p" "%p")
+					  ("-e" "none") ("%h")))
+	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "scp")
 	     (tramp-copy-args            (("-P" "%p") ("-p" "%k")
@@ -337,8 +349,9 @@
 					  ("-o" "StrictHostKeyChecking=no")))
 	     (tramp-default-port         22))
     ("scp1"  (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
-					  ("-1" "-e" "none")))
+             (tramp-login-args           (("-l" "%u") ("-p" "%p")
+					  ("-1") ("-e" "none") ("%h")))
+	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "scp")
 	     (tramp-copy-args            (("-1") ("-P" "%p") ("-p" "%k")
@@ -352,8 +365,9 @@
 					  ("-o" "StrictHostKeyChecking=no")))
 	     (tramp-default-port         22))
     ("scp2"  (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
-					  ("-2" "-e" "none")))
+             (tramp-login-args           (("-l" "%u") ("-p" "%p")
+					  ("-2") ("-e" "none") ("%h")))
+	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "scp")
 	     (tramp-copy-args            (("-2") ("-P" "%p") ("-p" "%k")
@@ -387,16 +401,18 @@
 	     (tramp-copy-recursive       t)
 	     (tramp-password-end-of-line nil))
     ("sftp"  (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
-					  ("-e" "none")))
+             (tramp-login-args           (("-l" "%u") ("-p" "%p")
+					  ("-e" "none") ("%h")))
+	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "sftp")
 	     (tramp-copy-args            nil)
 	     (tramp-copy-keep-date       nil)
 	     (tramp-password-end-of-line nil))
     ("rsync" (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
-					  ("-e" "none")))
+             (tramp-login-args           (("-l" "%u") ("-p" "%p")
+					  ("-e" "none") ("%h")))
+	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "rsync")
 	     (tramp-copy-args            (("-e" "ssh") ("-t" "%k") ("-r")))
@@ -406,10 +422,11 @@
 	     (tramp-password-end-of-line nil))
     ("rsyncc"
              (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
+             (tramp-login-args           (("-l" "%u") ("-p" "%p")
 					  ("-o" "ControlPath=%t.%%r@%%h:%%p")
 					  ("-o" "ControlMaster=yes")
-					  ("-e" "none")))
+					  ("-e" "none") ("%h")))
+	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "rsync")
 	     (tramp-copy-args            (("-t" "%k") ("-r")))
@@ -437,8 +454,9 @@
 	     (tramp-copy-keep-date       nil)
 	     (tramp-password-end-of-line nil))
     ("ssh"   (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
-					  ("-e" "none")))
+             (tramp-login-args           (("-l" "%u") ("-p" "%p")
+					  ("-e" "none") ("%h")))
+	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         nil)
 	     (tramp-copy-args            nil)
@@ -450,8 +468,9 @@
 					  ("-o" "StrictHostKeyChecking=no")))
 	     (tramp-default-port         22))
     ("ssh1"  (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
-					  ("-1" "-e" "none")))
+             (tramp-login-args           (("-l" "%u") ("-p" "%p")
+					  ("-1") ("-e" "none") ("%h")))
+	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         nil)
 	     (tramp-copy-args            nil)
@@ -463,8 +482,9 @@
 					  ("-o" "StrictHostKeyChecking=no")))
 	     (tramp-default-port         22))
     ("ssh2"  (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
-					  ("-2" "-e" "none")))
+             (tramp-login-args           (("-l" "%u") ("-p" "%p")
+					  ("-2") ("-e" "none") ("%h")))
+	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         nil)
 	     (tramp-copy-args            nil)
@@ -479,6 +499,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)
@@ -525,10 +546,11 @@
 	     (tramp-copy-keep-date       nil)
 	     (tramp-password-end-of-line nil))
     ("scpc"  (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
+             (tramp-login-args           (("-l" "%u") ("-p" "%p")
 					  ("-o" "ControlPath=%t.%%r@%%h:%%p")
 					  ("-o" "ControlMaster=yes")
-					  ("-e" "none")))
+					  ("-e" "none") ("%h")))
+	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "scp")
 	     (tramp-copy-args            (("-P" "%p") ("-p" "%k") ("-q")
@@ -542,8 +564,10 @@
 					  ("-o" "StrictHostKeyChecking=no")))
 	     (tramp-default-port         22))
     ("scpx"  (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
-					  ("-e" "none" "-t" "-t" "/bin/sh")))
+             (tramp-login-args           (("-l" "%u") ("-p" "%p")
+					  ("-e" "none") ("-t" "-t")
+					  ("%h") ("/bin/sh")))
+	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "scp")
 	     (tramp-copy-args            (("-p" "%k")))
@@ -555,8 +579,10 @@
 					  ("-o" "StrictHostKeyChecking=no")))
 	     (tramp-default-port         22))
     ("sshx"  (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
-					  ("-e" "none" "-t" "-t" "/bin/sh")))
+             (tramp-login-args           (("-l" "%u") ("-p" "%p")
+					  ("-e" "none") ("-t" "-t")
+					  ("%h") ("/bin/sh")))
+	     (tramp-async-args           (("-q")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         nil)
 	     (tramp-copy-args            nil)
@@ -576,8 +602,8 @@
 	     (tramp-copy-keep-date       nil)
 	     (tramp-password-end-of-line nil))
     ("plink" (tramp-login-program        "plink")
-	     (tramp-login-args           (("%h") ("-l" "%u") ("-P" "%p")
-					  ("-ssh")))
+	     (tramp-login-args           (("-l" "%u") ("-P" "%p")
+					  ("-ssh") ("%h")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         nil)
 	     (tramp-copy-args            nil)
@@ -586,8 +612,8 @@
 	     (tramp-default-port         22))
     ("plink1"
 	     (tramp-login-program        "plink")
-	     (tramp-login-args           (("%h") ("-l" "%u") ("-P" "%p")
-					  ("-1" "-ssh")))
+	     (tramp-login-args           (("-l" "%u") ("-P" "%p")
+					  ("-1" "-ssh") ("%h")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         nil)
 	     (tramp-copy-args            nil)
@@ -610,8 +636,8 @@
 	     (tramp-copy-keep-date       nil)
 	     (tramp-password-end-of-line nil))
     ("pscp"  (tramp-login-program        "plink")
-	     (tramp-login-args           (("%h") ("-l" "%u") ("-P" "%p")
-					  ("-ssh")))
+	     (tramp-login-args           (("-l" "%u") ("-P" "%p")
+					  ("-ssh") ("%h")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "pscp")
 	     (tramp-copy-args            (("-P" "%p") ("-scp") ("-p" "%k")))
@@ -619,8 +645,8 @@
 	     (tramp-password-end-of-line "xy") ;see docstring for "xy"
 	     (tramp-default-port         22))
     ("psftp" (tramp-login-program        "plink")
-	     (tramp-login-args           (("%h") ("-l" "%u") ("-P" "%p")
-					  ("-ssh")))
+	     (tramp-login-args           (("-l" "%u") ("-P" "%p")
+					  ("-ssh") ("%h")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "pscp")
 	     (tramp-copy-args            (("-P" "%p") ("-sftp") ("-p" "%k")))
@@ -662,6 +688,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
@@ -722,6 +753,16 @@
 `localhost' or the name of the local host.  Another host name is
 useful only in combination with `tramp-default-proxies-alist'.")
 
+(defun tramp-detect-ssh-controlmaster ()
+  "Call ssh to detect whether it supports the ControlMaster argument.
+This function may return nil when the argument is supported, but
+shouldn't return t when it isn't."
+  (ignore-errors
+    (with-temp-buffer
+      (call-process "ssh" nil t nil "-o" "ControlMaster")
+      (goto-char (point-min))
+      (search-forward-regexp "Missing ControlMaster argument" nil t))))
+
 (defcustom tramp-default-method
   ;; An external copy method seems to be preferred, because it is much
   ;; more performant for large files, and it hasn't too serious delays
@@ -729,9 +770,8 @@
   ;; permanent password queries.  Either a password agent like
   ;; "ssh-agent" or "Pageant" shall run, or the optional
   ;; password-cache.el or auth-sources.el packages shall be active for
-  ;; password caching.  "scpc" would be another good choice because of
-  ;; the "ControlMaster" option, but this is a more modern alternative
-  ;; in OpenSSH 4, which cannot be taken as default.
+  ;; password caching.  "scpc" is chosen if we detect that the user is
+  ;; running OpenSSH 4.0 or newer.
   (cond
    ;; PuTTY is installed.
    ((executable-find "pscp")
@@ -743,13 +783,15 @@
       "plink"))
    ;; There is an ssh installation.
    ((executable-find "scp")
-    (if	(or (fboundp 'password-read)
-	    (fboundp 'auth-source-user-or-password)
-	    ;; ssh-agent is running.
-	    (getenv "SSH_AUTH_SOCK")
-	    (getenv "SSH_AGENT_PID"))
-	"scp"
-      "ssh"))
+    (cond
+     ((tramp-detect-ssh-controlmaster) "scpc")
+     ((or (fboundp 'password-read)
+	  (fboundp 'auth-source-user-or-password)
+	  ;; ssh-agent is running.
+	  (getenv "SSH_AUTH_SOCK")
+	  (getenv "SSH_AGENT_PID"))
+      "scp")
+     (t "ssh")))
    ;; Fallback.
    (t "ftp"))
   "*Default method to use for transferring files.
@@ -870,9 +912,9 @@
 
 (defvar tramp-completion-function-alist nil
   "*Alist of methods for remote files.
-This is a list of entries of the form (NAME PAIR1 PAIR2 ...).
+This is a list of entries of the form \(NAME PAIR1 PAIR2 ...\).
 Each NAME stands for a remote access method.  Each PAIR is of the form
-\(FUNCTION FILE).  FUNCTION is responsible to extract user names and host
+\(FUNCTION FILE\).  FUNCTION is responsible to extract user names and host
 names from FILE for completion.  The following predefined FUNCTIONs exists:
 
  * `tramp-parse-rhosts'      for \"~/.rhosts\" like files,
@@ -998,6 +1040,7 @@
 ;; Solaris: /usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/opt/SUNWspro/bin
 ;; GNU/Linux (Debian, Suse): /bin:/usr/bin
 ;; FreeBSD: /usr/bin:/bin:/usr/sbin:/sbin: - beware trailing ":"!
+;; IRIX64: /usr/bin
 (defcustom tramp-remote-path
   '(tramp-default-remote-path "/usr/sbin" "/usr/local/bin"
     "/local/bin" "/local/freeware/bin" "/local/gnu/bin"
@@ -1024,9 +1067,9 @@
 
 (defcustom tramp-remote-process-environment
   `("HISTFILE=$HOME/.tramp_history" "HISTSIZE=1" "LC_ALL=C"
-    ,(concat "TERM=" tramp-terminal-type)
+    ,(format "TERM=%s" tramp-terminal-type)
     "EMACS=t" ;; Deprecated.
-    ,(format "INSIDE_EMACS=%s,tramp:%s" emacs-version tramp-version)
+    ,(format "INSIDE_EMACS='%s,tramp:%s'" emacs-version tramp-version)
     "CDPATH=" "HISTORY=" "MAIL=" "MAILCHECK=" "MAILPATH="
     "autocorrect=" "correct=")
 
@@ -1052,8 +1095,10 @@
 
 (defcustom tramp-shell-prompt-pattern
   ;; Allow a prompt to start right after a ^M since it indeed would be
-  ;; displayed at the beginning of the line (and Zsh uses it).
-  "\\(?:^\\|\r\\)[^#$%>\n]*#?[#$%>] *\\(\e\\[[0-9;]*[a-zA-Z] *\\)*"
+  ;; displayed at the beginning of the line (and Zsh uses it).  This
+  ;; regexp works only for GNU Emacs.
+  (concat (if (featurep 'xemacs) "" "\\(?:^\\|\r\\)")
+	  "[^#$%>\n]*#?[#$%>] *\\(\e\\[[0-9;]*[a-zA-Z] *\\)*")
   "Regexp to match prompts from remote shell.
 Normally, Tramp expects you to configure `shell-prompt-pattern'
 correctly, but sometimes it happens that you are connecting to a
@@ -1402,10 +1447,14 @@
 
 ;;;###autoload
 (defconst tramp-file-name-regexp-unified
-  "\\`/\\([^[/:]+\\|[^/]+]\\):"
+  (if (memq system-type '(cygwin windows-nt))
+      "\\`/\\([^[/:]\\{2,\\}\\|[^/]\\{2,\\}]\\):"
+    "\\`/\\([^[/:]+\\|[^/]+]\\):")
   "Value for `tramp-file-name-regexp' for unified remoting.
 Emacs (not XEmacs) uses a unified filename syntax for Ange-FTP and
-Tramp.  See `tramp-file-name-structure' for more explanations.")
+Tramp.  See `tramp-file-name-structure' for more explanations.
+
+On W32 systems, the volume letter must be ignored.")
 
 ;;;###autoload
 (defconst tramp-file-name-regexp-separate
@@ -1428,14 +1477,14 @@
 	(t (error "Wrong `tramp-syntax' defined")))
   "*Regular expression matching file names handled by Tramp.
 This regexp should match Tramp file names but no other file names.
-\(When tramp.el is loaded, this regular expression is prepended to
+When tramp.el is loaded, this regular expression is prepended to
 `file-name-handler-alist', and that is searched sequentially.  Thus,
 if the Tramp entry appears rather early in the `file-name-handler-alist'
 and is a bit too general, then some files might be considered Tramp
 files which are not really Tramp files.
 
 Please note that the entry in `file-name-handler-alist' is made when
-this file (tramp.el) is loaded.  This means that this variable must be set
+this file \(tramp.el\) is loaded.  This means that this variable must be set
 before loading tramp.el.  Alternatively, `file-name-handler-alist' can be
 updated after changing this variable.
 
@@ -1452,10 +1501,14 @@
 
 ;;;###autoload
 (defconst tramp-completion-file-name-regexp-unified
-  (concat tramp-root-regexp "[^/]*\\'")
+  (if (memq system-type '(cygwin windows-nt))
+      (concat tramp-root-regexp "[^/]\\{2,\\}\\'")
+    (concat tramp-root-regexp "[^/]*\\'"))
   "Value for `tramp-completion-file-name-regexp' for unified remoting.
 GNU Emacs uses a unified filename syntax for Tramp and Ange-FTP.
-See `tramp-file-name-structure' for more explanations.")
+See `tramp-file-name-structure' for more explanations.
+
+On W32 systems, the volume letter must be ignored.")
 
 ;;;###autoload
 (defconst tramp-completion-file-name-regexp-separate
@@ -1565,18 +1618,18 @@
 
 In the Emacs normally running Tramp, evaluate the above code
 \(replace \"xxx\" and \"yyy\" by the remote user and host name,
-respectively).  You can do this, for example, by pasting it into
+respectively\).  You can do this, for example, by pasting it into
 the `*scratch*' buffer and then hitting C-j with the cursor after the
 last closing parenthesis.  Note that it works only if you have configured
-\"ssh\" to run without password query, see ssh-agent(1).
+\"ssh\" to run without password query, see ssh-agent\(1\).
 
 You will see the number of bytes sent successfully to the remote host.
 If that number exceeds 1000, you can stop the execution by hitting
 C-g, because your Emacs is likely clean.
 
 When it is necessary to set `tramp-chunksize', you might consider to
-use an out-of-the-band method (like \"scp\") instead of an internal one
-\(like \"ssh\"), because setting `tramp-chunksize' to non-nil decreases
+use an out-of-the-band method \(like \"scp\"\) instead of an internal one
+\(like \"ssh\"\), because setting `tramp-chunksize' to non-nil decreases
 performance.
 
 If your Emacs is buggy, the code stops and gives you an indication
@@ -1745,7 +1798,7 @@
     $stat[2],
     $stat[1] >> 16 & 0xffff,
     $stat[1] & 0xffff
-);' \"$1\" \"$2\" \"$3\" 2>/dev/null"
+);' \"$1\" \"$2\" 2>/dev/null"
   "Perl script to produce output suitable for use with `file-attributes'
 on the remote file system.
 Escape sequence %s is replaced with name of Perl binary.
@@ -1798,7 +1851,7 @@
         $stat[0] >> 16 & 0xffff,
         $stat[0] & 0xffff);
 }
-printf(\")\\n\");' \"$1\" \"$2\" \"$3\" 2>/dev/null"
+printf(\")\\n\");' \"$1\" \"$2\" 2>/dev/null"
   "Perl script implementing `directory-files-attributes' as Lisp `read'able
 output.
 Escape sequence %s is replaced with name of Perl binary.
@@ -1930,13 +1983,13 @@
 
 (defconst tramp-vc-registered-read-file-names
   "echo \"(\"
-for file in \"$@\"; do
-    if %s $file; then
+while read file; do
+    if %s \"$file\"; then
 	echo \"(\\\"$file\\\" \\\"file-exists-p\\\" t)\"
     else
 	echo \"(\\\"$file\\\" \\\"file-exists-p\\\" nil)\"
     fi
-    if %s $file; then
+    if %s \"$file\"; then
 	echo \"(\\\"$file\\\" \\\"file-readable-p\\\" t)\"
     else
 	echo \"(\\\"$file\\\" \\\"file-readable-p\\\" nil)\"
@@ -1945,7 +1998,9 @@
 echo \")\""
   "Script to check existence of VC related files.
 It must be send formatted with two strings; the tests for file
-existence, and file readability.")
+existence, and file readability.  Input shall be read via
+here-document, otherwise the command could exceed maximum length
+of command line.")
 
 (defconst tramp-file-mode-type-map
   '((0  . "-")  ; Normal file (SVID-v2 and XPG2)
@@ -2024,6 +2079,8 @@
     (dired-uncache . tramp-handle-dired-uncache)
     (set-visited-file-modtime . tramp-handle-set-visited-file-modtime)
     (verify-visited-file-modtime . tramp-handle-verify-visited-file-modtime)
+    (file-selinux-context . tramp-handle-file-selinux-context)
+    (set-file-selinux-context . tramp-handle-set-file-selinux-context)
     (vc-registered . tramp-handle-vc-registered))
   "Alist of handler functions.
 Operations not mentioned here will be handled by the normal Emacs functions.")
@@ -2080,7 +2137,7 @@
 	      (setq fn (symbol-name btf))
 	      (unless (and (string-match "^tramp" fn)
 			   (not (string-match
-				 "^tramp\\(-debug\\)?\\(-message\\|-error\\)$"
+				 "^tramp\\(-debug\\)?\\(-message\\|-error\\|-compat-funcall\\)$"
 				 fn)))
 		(setq fn nil)))
 	    (setq btn (1+ btn))))
@@ -2169,7 +2226,9 @@
   (save-window-excursion
     (unwind-protect
 	(apply 'tramp-error vec-or-proc signal fmt-string args)
-      (when (and vec-or-proc (not (zerop tramp-verbose)))
+      (when (and vec-or-proc
+		 (not (zerop tramp-verbose))
+		 (not (tramp-completion-mode-p)))
 	(let ((enable-recursive-minibuffers t))
 	  (pop-to-buffer
 	   (or (and (bufferp buffer) buffer)
@@ -2226,7 +2285,7 @@
 (font-lock-add-keywords 'emacs-lisp-mode '("\\<with-file-property\\>"))
 
 (defmacro with-connection-property (key property &rest body)
-  "Checks in Tramp for property PROPERTY, otherwise executes BODY and set."
+  "Check in Tramp for property PROPERTY, otherwise executes BODY and set."
   `(let ((value (tramp-get-connection-property ,key ,property 'undef)))
     (when (eq value 'undef)
       ;; We cannot pass ,@body as parameter to
@@ -2240,7 +2299,45 @@
 (put 'with-connection-property 'edebug-form-spec t)
 (font-lock-add-keywords 'emacs-lisp-mode '("\\<with-connection-property\\>"))
 
-(eval-and-compile			; silence compiler
+(defun tramp-progress-reporter-update (reporter &optional value)
+  (let* ((parameters (cdr reporter))
+	 (message (aref parameters 3)))
+    (when (string-match message (or (current-message) ""))
+      (funcall 'progress-reporter-update reporter value))))
+
+(defmacro with-progress-reporter (vec level message &rest body)
+  "Executes BODY, spinning a progress reporter with MESSAGE.
+If LEVEL does not fit for visible messages, or if this is a
+nested call of the macro, there are only traces without a visible
+progress reporter."
+  `(let (pr tm)
+     (tramp-message ,vec ,level "%s..." ,message)
+     ;; We start a pulsing progress reporter after 3 seconds.  Feature
+     ;; introduced in Emacs 24.1.
+     (when (and tramp-message-show-message
+		;; Display only when there is a minimum level.
+		(<= ,level (min tramp-verbose 3)))
+       (condition-case nil
+	   (setq pr (tramp-compat-funcall 'make-progress-reporter ,message)
+		 tm (when pr
+		      (run-at-time 3 0.1 'tramp-progress-reporter-update pr)))
+	 (error nil)))
+     (unwind-protect
+	 ;; Execute the body.  Unset `tramp-message-show-message' when
+	 ;; the timer object is created, in order to suppress
+	 ;; concurrent timers.
+	 (let ((tramp-message-show-message
+		(and tramp-message-show-message (not tm))))
+	   ,@body)
+       ;; Stop progress reporter.
+       (if tm (tramp-compat-funcall 'cancel-timer tm))
+       (tramp-message ,vec ,level "%s...done" ,message))))
+
+(put 'with-progress-reporter 'lisp-indent-function 3)
+(put 'with-progress-reporter 'edebug-form-spec t)
+(font-lock-add-keywords 'emacs-lisp-mode '("\\<with-progress-reporter\\>"))
+
+(eval-and-compile			;; Silence compiler.
   (if (memq system-type '(cygwin windows-nt))
       (defun tramp-drop-volume-letter (name)
 	"Cut off unnecessary drive letter from file NAME.
@@ -2350,15 +2447,16 @@
 special handling of `substitute-in-file-name'."
   (when (symbol-value 'minibuffer-completing-file-name)
     (setq tramp-rfn-eshadow-overlay
-	  (funcall (symbol-function 'make-overlay)
-		   (funcall (symbol-function 'minibuffer-prompt-end))
-		   (funcall (symbol-function 'minibuffer-prompt-end))))
+	  (tramp-compat-funcall
+	   'make-overlay
+	   (tramp-compat-funcall 'minibuffer-prompt-end)
+	   (tramp-compat-funcall 'minibuffer-prompt-end)))
     ;; Copy rfn-eshadow-overlay properties.
-    (let ((props (funcall (symbol-function 'overlay-properties)
-			  (symbol-value 'rfn-eshadow-overlay))))
+    (let ((props (tramp-compat-funcall
+		  'overlay-properties (symbol-value 'rfn-eshadow-overlay))))
       (while props
-	(funcall (symbol-function 'overlay-put)
-		 tramp-rfn-eshadow-overlay (pop props) (pop props))))))
+	(tramp-compat-funcall
+	 'overlay-put tramp-rfn-eshadow-overlay (pop props) (pop props))))))
 
 (when (boundp 'rfn-eshadow-setup-minibuffer-hook)
   (add-hook 'rfn-eshadow-setup-minibuffer-hook
@@ -2377,10 +2475,12 @@
 `file-name-shadow-mode'; the minibuffer should have already
 been set up by `rfn-eshadow-setup-minibuffer'."
   ;; In remote files name, there is a shadowing just for the local part.
-  (let ((end (or (funcall (symbol-function 'overlay-end)
-			  (symbol-value 'rfn-eshadow-overlay))
-		 (funcall (symbol-function 'minibuffer-prompt-end)))))
-    (when (file-remote-p (buffer-substring-no-properties end (point-max)))
+  (let ((end (or (tramp-compat-funcall
+		  'overlay-end (symbol-value 'rfn-eshadow-overlay))
+		 (tramp-compat-funcall 'minibuffer-prompt-end))))
+    (when
+	(file-remote-p
+	 (tramp-compat-funcall 'buffer-substring-no-properties end (point-max)))
       (save-excursion
 	(save-restriction
 	  (narrow-to-region
@@ -2390,8 +2490,9 @@
 	   (point-max))
 	  (let ((rfn-eshadow-overlay tramp-rfn-eshadow-overlay)
 		(rfn-eshadow-update-overlay-hook nil))
-	    (move-overlay rfn-eshadow-overlay (point-max) (point-max))
-	    (funcall (symbol-function 'rfn-eshadow-update-overlay))))))))
+	    (tramp-compat-funcall
+	     'move-overlay rfn-eshadow-overlay (point-max) (point-max))
+	    (tramp-compat-funcall 'rfn-eshadow-update-overlay)))))))
 
 (when (boundp 'rfn-eshadow-update-overlay-hook)
   (add-hook 'rfn-eshadow-update-overlay-hook
@@ -2451,7 +2552,7 @@
       (unless ln
 	(tramp-error
 	 l 'file-error
-	 "Making a symbolic link. ln(1) does not exist on the remote host."))
+	 "Making a symbolic link.  ln(1) does not exist on the remote host."))
 
       ;; Do the 'confirm if exists' thing.
       (when (file-exists-p linkname)
@@ -2472,6 +2573,9 @@
 	      (tramp-file-name-localname
 	       (tramp-dissect-file-name (expand-file-name filename)))))
 
+      (tramp-flush-file-property l (file-name-directory l-localname))
+      (tramp-flush-file-property l l-localname)
+
       ;; Right, they are on the same host, regardless of user, method, etc.
       ;; We now make the link on the remote machine. This will occur as the user
       ;; that FILENAME belongs to.
@@ -2507,13 +2611,13 @@
 	(tramp-error v 'file-error "Cannot load nonexistent file `%s'" file)))
     (if (not (file-exists-p file))
 	nil
-      (unless nomessage (tramp-message v 0 "Loading %s..." file))
-      (let ((local-copy (file-local-copy file)))
-	;; MUST-SUFFIX doesn't exist on XEmacs, so let it default to nil.
-	(unwind-protect
-	    (load local-copy noerror t t)
-	  (delete-file local-copy)))
-      (unless nomessage (tramp-message v 0 "Loading %s...done" file))
+      (let ((tramp-message-show-message (not nomessage)))
+	(with-progress-reporter v 0 (format "Loading %s" file)
+	  (let ((local-copy (file-local-copy file)))
+	    ;; MUST-SUFFIX doesn't exist on XEmacs, so let it default to nil.
+	    (unwind-protect
+		(load local-copy noerror t t)
+	      (delete-file local-copy)))))
       t)))
 
 ;; Localname manipulation functions that grok Tramp localnames...
@@ -2816,7 +2920,9 @@
   (tramp-send-command-and-read
    vec
    (format
-    "((%s %s || %s -h %s) && %s -c '((\"%%N\") %%h %s %s %%X.0 %%Y.0 %%Z.0 %%s.0 \"%%A\" t %%i.0 -1)' %s || echo nil)"
+    ;; On Opsware, pdksh (which is the true name of ksh there) doesn't
+    ;; parse correctly the sequence "((".  Therefore, we add a space.
+    "( (%s %s || %s -h %s) && %s -c '( (\"%%N\") %%h %s %s %%X.0 %%Y.0 %%Z.0 %%s.0 \"%%A\" t %%i.0 -1)' %s || echo nil)"
     (tramp-get-file-exists-command vec)
     (tramp-shell-quote-argument localname)
     (tramp-get-test-command vec)
@@ -2869,12 +2975,14 @@
 function directly, unless those two cases are already taken care
 of."
   (with-current-buffer buf
-    ;; There is no file visiting the buffer, or the buffer has no
-    ;; recorded last modification time.
-    (if (or (not (buffer-file-name))
-	    (eq (visited-file-modtime) 0))
-	t
-      (let ((f (buffer-file-name)))
+    (let ((f (buffer-file-name)))
+      ;; There is no file visiting the buffer, or the buffer has no
+      ;; recorded last modification time, or there is no established
+      ;; connection.
+      (if (or (not f)
+	      (eq (visited-file-modtime) 0)
+	      (not (tramp-file-name-handler 'file-remote-p f nil 'connected)))
+	  t
 	(with-parsed-tramp-file-name f nil
 	  (tramp-flush-file-property v localname)
 	  (let* ((attr (file-attributes f))
@@ -2933,17 +3041,11 @@
 	 (let ((time (if (or (null time) (equal time '(0 0)))
 			 (current-time)
 		       time))
-	       (utc
-		;; With GNU Emacs, `format-time-string' has an
-		;; optional parameter UNIVERSAL.  This is preferred,
-		;; because we could handle the case when the remote
-		;; host is located in a different time zone as the
-		;; local host.
-		(and (functionp 'subr-arity)
-		     (subrp (symbol-function 'format-time-string))
-		     (= 3 (cdr (funcall (symbol-function 'subr-arity)
-					(symbol-function
-					 'format-time-string)))))))
+	       ;; With GNU Emacs, `format-time-string' has an optional
+	       ;; parameter UNIVERSAL.  This is preferred, because we
+	       ;; could handle the case when the remote host is
+	       ;; located in a different time zone as the local host.
+	       (utc (not (featurep 'xemacs))))
 	   (tramp-send-command-and-check
 	    v (format "%s touch -t %s %s"
 		      (if utc "TZ=UTC; export TZ;" "")
@@ -2992,6 +3094,59 @@
 	 "chown" nil nil nil
          (format "%d:%d" uid gid) (tramp-shell-quote-argument filename))))))
 
+(defun tramp-remote-selinux-p (vec)
+  "Check, whether SELINUX is enabled on the remote host."
+  (with-connection-property (tramp-get-connection-process vec) "selinux-p"
+    (let ((result (tramp-find-executable
+		   vec "getenforce" (tramp-get-remote-path vec) t t)))
+      (and result
+	   (string-equal
+	    (tramp-send-command-and-read
+	     vec (format "echo \\\"`%S`\\\"" result))
+	    "Enforcing")))))
+
+(defun tramp-handle-file-selinux-context (filename)
+  "Like `file-selinux-context' for Tramp files."
+  (with-parsed-tramp-file-name filename nil
+    (with-file-property v localname "file-selinux-context"
+      (let ((context '(nil nil nil nil))
+	    (regexp (concat "\\([a-z0-9_]+\\):" "\\([a-z0-9_]+\\):"
+			    "\\([a-z0-9_]+\\):" "\\([a-z0-9_]+\\)")))
+	(when (and (tramp-remote-selinux-p v)
+		   (zerop (tramp-send-command-and-check
+			   v (format
+			      "%s -d -Z %s"
+			      (tramp-get-ls-command v)
+			      (tramp-shell-quote-argument localname)))))
+	  (with-current-buffer (tramp-get-connection-buffer v)
+	    (goto-char (point-min))
+	    (when (re-search-forward regexp (tramp-compat-line-end-position) t)
+	      (setq context (list (match-string 1) (match-string 2)
+				  (match-string 3) (match-string 4))))))
+	;; Return the context.
+	context))))
+
+(defun tramp-handle-set-file-selinux-context (filename context)
+  "Like `set-file-selinux-context' for Tramp files."
+  (with-parsed-tramp-file-name filename nil
+    (if (and (consp context)
+	     (tramp-remote-selinux-p v)
+	     (zerop (tramp-send-command-and-check
+		     v (format "chcon %s %s %s %s %s"
+			       (if (stringp (nth 0 context))
+				   (format "--user=%s" (nth 0 context)) "")
+			       (if (stringp (nth 1 context))
+				   (format "--role=%s" (nth 1 context)) "")
+			       (if (stringp (nth 2 context))
+				   (format "--type=%s" (nth 2 context)) "")
+			       (if (stringp (nth 3 context))
+				   (format "--range=%s" (nth 3 context)) "")
+			       (tramp-shell-quote-argument localname)))))
+	(tramp-set-file-property v localname "file-selinux-context" context)
+      (tramp-set-file-property v localname "file-selinux-context" 'undef)))
+  ;; We always return nil.
+  nil)
+
 ;; Simple functions using the `test' command.
 
 (defun tramp-handle-file-executable-p (filename)
@@ -3165,7 +3320,7 @@
   (when (file-directory-p directory)
     (setq directory (expand-file-name directory))
     (let* ((temp
-	    (tramp-compat-copy-tree
+	    (copy-tree
 	     (with-parsed-tramp-file-name directory nil
 	       (with-file-property
 		   v localname
@@ -3296,7 +3451,12 @@
                           (tramp-shell-quote-argument localname)
                           (tramp-shell-quote-argument filename)
                           (if (symbol-value
-			       'read-file-name-completion-ignore-case)
+			       ;; `read-file-name-completion-ignore-case'
+			       ;; is introduced with Emacs 22.1.
+			       (if (boundp
+				    'read-file-name-completion-ignore-case)
+				   'read-file-name-completion-ignore-case
+				 'completion-ignore-case))
 			      1 0)))
 
               (format (concat
@@ -3381,7 +3541,6 @@
             "file-name-all-completions"
             result))))))))
 
-;; The following isn't needed for Emacs 20 but for 19.34?
 (defun tramp-handle-file-name-completion
   (filename directory &optional predicate)
   "Like `file-name-completion' for Tramp files."
@@ -3430,10 +3589,9 @@
 	 (buffer-name))))))
 
 (defun tramp-handle-copy-file
-  (filename newname &optional ok-if-already-exists keep-date preserve-uid-gid)
+  (filename newname &optional ok-if-already-exists keep-date
+	    preserve-uid-gid preserve-selinux-context)
   "Like `copy-file' for Tramp files."
-  ;; Check if both files are local -- invoke normal copy-file.
-  ;; Otherwise, use Tramp from local system.
   (setq filename (expand-file-name filename))
   (setq newname (expand-file-name newname))
   (cond
@@ -3441,8 +3599,14 @@
    ((or (tramp-tramp-file-p filename)
 	(tramp-tramp-file-p newname))
     (tramp-do-copy-or-rename-file
-     'copy filename newname ok-if-already-exists keep-date preserve-uid-gid))
+     'copy filename newname ok-if-already-exists keep-date
+     preserve-uid-gid preserve-selinux-context))
    ;; Compat section.
+   (preserve-selinux-context
+    (tramp-run-real-handler
+     'copy-file
+     (list filename newname ok-if-already-exists keep-date
+	   preserve-uid-gid preserve-selinux-context)))
    (preserve-uid-gid
     (tramp-run-real-handler
      'copy-file
@@ -3503,7 +3667,8 @@
      'rename-file (list filename newname ok-if-already-exists))))
 
 (defun tramp-do-copy-or-rename-file
-  (op filename newname &optional ok-if-already-exists keep-date preserve-uid-gid)
+  (op filename newname &optional ok-if-already-exists keep-date
+      preserve-uid-gid preserve-selinux-context)
   "Copy or rename a remote file.
 OP must be `copy' or `rename' and indicates the operation to perform.
 FILENAME specifies the file to copy or rename, NEWNAME is the name of
@@ -3512,6 +3677,7 @@
 KEEP-DATE means to make sure that NEWNAME has the same timestamp
 as FILENAME.  PRESERVE-UID-GID, when non-nil, instructs to keep
 the uid and gid if both files are on the same host.
+PRESERVE-SELINUX-CONTEXT activates selinux commands.
 
 This function is invoked by `tramp-handle-copy-file' and
 `tramp-handle-rename-file'.  It is an error if OP is neither of `copy'
@@ -3519,26 +3685,30 @@
   (unless (memq op '(copy rename))
     (error "Unknown operation `%s', must be `copy' or `rename'" op))
   (let ((t1 (tramp-tramp-file-p filename))
-	(t2 (tramp-tramp-file-p newname)))
-
-    (when (and (not ok-if-already-exists) (file-exists-p newname))
-      (with-parsed-tramp-file-name (if t1 filename newname) nil
-	(tramp-error
-	 v 'file-already-exists "File %s already exists" newname)))
+	(t2 (tramp-tramp-file-p newname))
+	(context (and preserve-selinux-context
+		      (apply 'file-selinux-context (list filename))))
+	pr tm)
 
     (with-parsed-tramp-file-name (if t1 filename newname) nil
-      (tramp-message v 0 "Transferring %s to %s..." filename newname))
-
-    (prog1
+      (when (and (not ok-if-already-exists) (file-exists-p newname))
+	(tramp-error
+	 v 'file-already-exists "File %s already exists" newname))
+
+      (with-progress-reporter
+	  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.
+	       ;; 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
@@ -3550,9 +3720,9 @@
 		(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
+	       ;; 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
@@ -3565,42 +3735,41 @@
 
 	 ;; One file is a Tramp file, the other one is local.
 	 ((or t1 t2)
-	  (with-parsed-tramp-file-name (if t1 filename newname) nil
-	    (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)))))
+	  (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")))
 
-      ;; 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 nil
-	  (tramp-flush-file-property v (file-name-directory localname))
-	  (tramp-flush-file-property v localname)))
-
-      ;; When newname did exist, we have wrong cached values.
-      (when t2
-	(with-parsed-tramp-file-name newname nil
-	  (tramp-flush-file-property v (file-name-directory localname))
-	  (tramp-flush-file-property v localname)))
-
-      (with-parsed-tramp-file-name (if t1 filename newname) nil
-	(tramp-message v 0 "Transferring %s to %s...done" filename newname)))))
+	;; 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.
@@ -3649,9 +3818,13 @@
 			    "Unknown operation `%s', must be `copy' or `rename'"
 			    op))))
 	     (localname1
-	      (if t1 (tramp-handle-file-remote-p filename 'localname) filename))
+	      (if t1
+		  (tramp-file-name-handler 'file-remote-p filename 'localname)
+		filename))
 	     (localname2
-	      (if t2 (tramp-handle-file-remote-p newname 'localname) newname))
+	      (if t2
+		  (tramp-file-name-handler 'file-remote-p newname 'localname)
+		newname))
 	     (prefix (file-remote-p (if t1 filename newname)))
              cmd-result)
 
@@ -3813,7 +3986,7 @@
 	      ;; Save exit.
 	      (condition-case nil
 		  (if dir-flag
-		      (delete-directory
+		      (tramp-compat-delete-directory
 		       (expand-file-name ".." tmpfile) 'recursive)
 		    (delete-file tmpfile))
 		(error))))
@@ -3840,10 +4013,11 @@
 	      port (or (and port (number-to-string port)) ""))
 
 	;; Compose copy command.
-	(setq spec `((?h . ,host) (?u . ,user) (?p . ,port)
-		     (?t . ,(tramp-get-connection-property
-			     (tramp-get-connection-process v) "temp-file" ""))
-		     (?k . ,(if keep-date " " "")))
+	(setq spec (format-spec-make
+		    ?h host ?u user ?p port
+		    ?t (tramp-get-connection-property
+			(tramp-get-connection-process v) "temp-file" "")
+		    ?k (if keep-date " " ""))
 	      copy-program (tramp-get-method-parameter
 			    method 'tramp-copy-program)
 	      copy-keep-date (tramp-get-method-parameter
@@ -3933,7 +4107,7 @@
       (unless (eq op 'copy)
 	(if (file-regular-p filename)
 	    (delete-file filename)
-	  (delete-directory filename 'recursive))))))
+	  (tramp-compat-delete-directory filename 'recursive))))))
 
 (defun tramp-handle-make-directory (dir &optional parents)
   "Like `make-directory' for Tramp files."
@@ -3962,16 +4136,18 @@
 		     (tramp-shell-quote-argument localname))))
       (tramp-error v 'file-error "Couldn't delete %s" directory))))
 
-(defun tramp-handle-delete-file (filename)
+(defun tramp-handle-delete-file (filename &optional trash)
   "Like `delete-file' for Tramp files."
   (setq filename (expand-file-name filename))
   (with-parsed-tramp-file-name filename nil
     (tramp-flush-file-property v (file-name-directory localname))
     (tramp-flush-file-property v localname)
-    (unless (zerop (tramp-send-command-and-check
-		    v
-		    (format "rm -f %s"
-			    (tramp-shell-quote-argument localname))))
+    (unless
+	(zerop
+	 (tramp-send-command-and-check
+	  v (format "%s %s"
+		    (or (and trash (tramp-get-remote-trash v)) "rm -f")
+		    (tramp-shell-quote-argument localname))))
       (tramp-error v 'file-error "Couldn't delete %s" filename))))
 
 ;; Dired.
@@ -4033,37 +4209,37 @@
 	       nil)
 	      ((and suffix (nth 2 suffix))
 	       ;; We found an uncompression rule.
-	       (tramp-message v 0 "Uncompressing %s..." file)
-	       (when (zerop (tramp-send-command-and-check
-			     v (concat (nth 2 suffix) " "
-				       (tramp-shell-quote-argument localname))))
-		 (tramp-message v 0 "Uncompressing %s...done" file)
-		 ;; `dired-remove-file' is not defined in XEmacs
-		 (funcall (symbol-function 'dired-remove-file) file)
-		 (string-match (car suffix) file)
-		 (concat (substring file 0 (match-beginning 0)))))
+	       (with-progress-reporter v 0 (format "Uncompressing %s" file)
+		 (when (zerop
+			(tramp-send-command-and-check
+			 v (concat (nth 2 suffix) " "
+				   (tramp-shell-quote-argument localname))))
+		   ;; `dired-remove-file' is not defined in XEmacs.
+		   (tramp-compat-funcall 'dired-remove-file file)
+		   (string-match (car suffix) file)
+		   (concat (substring file 0 (match-beginning 0))))))
 	      (t
 	       ;; We don't recognize the file as compressed, so compress it.
 	       ;; Try gzip.
-	       (tramp-message v 0 "Compressing %s..." file)
-	       (when (zerop (tramp-send-command-and-check
-			     v (concat "gzip -f "
-				       (tramp-shell-quote-argument localname))))
-		 (tramp-message v 0 "Compressing %s...done" file)
-		 ;; `dired-remove-file' is not defined in XEmacs
-		 (funcall (symbol-function 'dired-remove-file) file)
-		 (cond ((file-exists-p (concat file ".gz"))
-			(concat file ".gz"))
-		       ((file-exists-p (concat file ".z"))
-			(concat file ".z"))
-		       (t nil)))))))))
+	       (with-progress-reporter v 0 (format "Compressing %s" file)
+		 (when (zerop
+			(tramp-send-command-and-check
+			 v (concat "gzip -f "
+				   (tramp-shell-quote-argument localname))))
+		   ;; `dired-remove-file' is not defined in XEmacs.
+		   (tramp-compat-funcall 'dired-remove-file file)
+		   (cond ((file-exists-p (concat file ".gz"))
+			  (concat file ".gz"))
+			 ((file-exists-p (concat file ".z"))
+			  (concat file ".z"))
+			 (t nil))))))))))
 
 (defun tramp-handle-dired-uncache (dir &optional dir-p)
   "Like `dired-uncache' for Tramp files."
   ;; DIR-P is valid for XEmacs only.
   (with-parsed-tramp-file-name
       (if (or dir-p (file-directory-p dir)) dir (file-name-directory dir)) nil
-    (tramp-flush-file-property v localname)))
+    (tramp-flush-directory-property v localname)))
 
 ;; Pacify byte-compiler.  The function is needed on XEmacs only.  I'm
 ;; not sure at all that this is the right way to do it, but let's hope
@@ -4150,13 +4326,11 @@
 	(forward-line -2)
 	(when (looking-at "//SUBDIRED//")
 	  (forward-line -1))
-	(when (looking-at "//DIRED//")
-	  (let ((end (tramp-compat-line-end-position))
-		(linebeg (point)))
+	(when (looking-at "//DIRED//\\s-+")
+	  (let ((databeg (match-end 0))
+		(end (tramp-compat-line-end-position)))
 	    ;; Now read the numeric positions of file names.
-	    (goto-char linebeg)
-	    (forward-word 1)
-	    (forward-char 3)
+	    (goto-char databeg)
 	    (while (< (point) end)
 	      (let ((start (+ beg (read (current-buffer))))
 		    (end (+ beg (read (current-buffer)))))
@@ -4201,7 +4375,7 @@
   (unless (file-name-absolute-p name)
     (setq name (concat (file-name-as-directory dir) name)))
   ;; If NAME is not a Tramp file, run the real handler.
-  (if (not (tramp-tramp-file-p name))
+  (if (not (tramp-connectable-p name))
       (tramp-run-real-handler 'expand-file-name (list name nil))
     ;; Dissect NAME.
     (with-parsed-tramp-file-name name nil
@@ -4334,20 +4508,30 @@
   (with-parsed-tramp-file-name default-directory nil
     (tramp-find-executable v command (tramp-get-remote-path v) t)))
 
+(defun tramp-process-sentinel (proc event)
+  "Flush file caches."
+  (unless (memq (process-status proc) '(run open))
+    (let ((vec (tramp-get-connection-property proc "vector" nil)))
+      (when vec
+	(tramp-message vec 5 "Sentinel called: `%s' `%s'" proc event)
+        (tramp-flush-directory-property vec "")))))
+
 ;; We use BUFFER also as connection buffer during setup. Because of
 ;; this, its original contents must be saved, and restored once
 ;; connection has been setup.
 (defun tramp-handle-start-file-process (name buffer program &rest args)
   "Like `start-file-process' for Tramp files."
   (with-parsed-tramp-file-name default-directory nil
-    (unless (stringp program)
-      (tramp-error
-       v 'file-error "pty association is not supported for `%s'" name))
     (unwind-protect
-	(let ((command (format "cd %s; exec %s"
-			       (tramp-shell-quote-argument localname)
-			       (mapconcat 'tramp-shell-quote-argument
-					  (cons program args) " ")))
+	;; When PROGRAM is nil, we just provide a tty.
+	(let ((command
+	       (when (stringp program)
+		 (format "cd %s; exec %s"
+			 (tramp-shell-quote-argument localname)
+			 (mapconcat 'tramp-shell-quote-argument
+				    (cons program args) " "))))
+	      (tramp-process-connection-type
+	       (or (null program) tramp-process-connection-type))
 	      (name1 name)
 	      (i 0))
 	  (unless buffer
@@ -4367,14 +4551,21 @@
 	  (with-current-buffer (tramp-get-connection-buffer v)
 	    (clear-visited-file-modtime)
 	    (narrow-to-region (point-max) (point-max)))
-	  ;; Send the command.  `tramp-send-command' opens a new
-	  ;; connection.
-	  (tramp-send-command v command nil t) ; nooutput
-	  ;; Set query flag for this process.
-	  (tramp-set-process-query-on-exit-flag
-	   (tramp-get-connection-process v) t)
-	  ;; Return process.
-	  (tramp-get-connection-process v))
+	  (if command
+	      ;; Send the command.
+	      (tramp-send-command v command nil t) ; nooutput
+	    ;; Check, whether a pty is associated.
+	    (tramp-maybe-open-connection v)
+	    (unless (process-get (tramp-get-connection-process v) 'remote-tty)
+	      (tramp-error
+	       v 'file-error "pty association is not supported for `%s'" name)))
+	  (let ((p (tramp-get-connection-process v)))
+	    ;; Set sentinel and query flag for this process.
+	    (tramp-set-connection-property p "vector" v)
+	    (set-process-sentinel p 'tramp-process-sentinel)
+	    (tramp-set-process-query-on-exit-flag p t)
+	    ;; Return process.
+	    p))
       ;; Save exit.
       (with-current-buffer (tramp-get-connection-buffer v)
 	(if (string-match tramp-temp-buffer-name (buffer-name))
@@ -4450,7 +4641,9 @@
 	(setq outbuf (current-buffer))))
       (when stderr (setq command (format "%s 2>%s" command stderr)))
 
-      ;; Send the command.  It might not return in time, so we protect it.
+      ;; Send the command.  It might not return in time, so we protect
+      ;; it.  Call it in a subshell, in order to preserve working
+      ;; directory.
       (condition-case nil
 	  (unwind-protect
               (setq ret
@@ -4458,7 +4651,7 @@
                      v (format "\\cd %s; %s"
                                (tramp-shell-quote-argument localname)
                                command)
-		     nil t))
+		     t t))
 	    ;; We should show the output anyway.
 	    (when outbuf
 	      (with-current-buffer outbuf
@@ -4526,7 +4719,12 @@
   (let* ((asynchronous (string-match "[ \t]*&[ \t]*\\'" command))
 	 ;; We cannot use `shell-file-name' and `shell-command-switch',
 	 ;; they are variables of the local host.
-	 (args (list "/bin/sh" "-c" (substring command 0 asynchronous)))
+	 (args (list
+		(tramp-get-method-parameter
+		 (tramp-file-name-method
+		  (tramp-dissect-file-name default-directory))
+		 'tramp-remote-sh)
+		"-c" (substring command 0 asynchronous)))
 	 current-buffer-p
 	 (output-buffer
 	  (cond
@@ -4595,8 +4793,7 @@
 	  ;; There's some output, display it.
 	  (when (with-current-buffer output-buffer (> (point-max) (point-min)))
 	    (if (functionp 'display-message-or-buffer)
-		(funcall (symbol-function 'display-message-or-buffer)
-			 output-buffer)
+		(tramp-compat-funcall 'display-message-or-buffer output-buffer)
 	      (pop-to-buffer output-buffer))))))))
 
 ;; File Editing.
@@ -4613,29 +4810,28 @@
        v 'file-error
        "Cannot make local copy of non-existing file `%s'" filename))
 
-    (let ((rem-enc (tramp-get-remote-coding v "remote-encoding"))
-	  (loc-dec (tramp-get-local-coding v "local-decoding"))
-	  (tmpfile (tramp-compat-make-temp-file filename)))
+    (let* ((size (nth 7 (file-attributes filename)))
+	   (rem-enc (tramp-get-inline-coding v "remote-encoding" size))
+	   (loc-dec (tramp-get-inline-coding v "local-decoding" size))
+	   (tmpfile (tramp-compat-make-temp-file filename)))
 
       (condition-case err
 	  (cond
 	   ;; `copy-file' handles direct copy and out-of-band methods.
 	   ((or (tramp-local-host-p v)
-		(tramp-method-out-of-band-p
-		 v (nth 7 (file-attributes filename))))
+		(tramp-method-out-of-band-p v size))
 	    (copy-file filename tmpfile t t))
 
 	   ;; Use inline encoding for file transfer.
 	   (rem-enc
 	    (save-excursion
-	      (tramp-message v 5 "Encoding remote file %s..." filename)
-	      (tramp-barf-unless-okay
-	       v
-	       (format "%s < %s" rem-enc (tramp-shell-quote-argument localname))
-	       "Encoding remote file failed")
-	      (tramp-message v 5 "Encoding remote file %s...done" filename)
-
-	      (if (and (symbolp loc-dec) (fboundp loc-dec))
+	      (with-progress-reporter
+	       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"))
+
+	      (if (functionp loc-dec)
 		  ;; If local decoding is a function, we call it.  We
 		  ;; must disable multibyte, because
 		  ;; `uudecode-decode-region' doesn't handle it
@@ -4643,15 +4839,15 @@
 		  (with-temp-buffer
 		    (set-buffer-multibyte nil)
 		    (insert-buffer-substring (tramp-get-buffer v))
-		    (tramp-message
-		     v 5 "Decoding remote file %s with function %s..."
-		     filename loc-dec)
-		    (funcall loc-dec (point-min) (point-max))
-		    ;; Unset `file-name-handler-alist'.  Otherwise,
-		    ;; epa-file gets confused.
-		    (let (file-name-handler-alist
-			  (coding-system-for-write 'binary))
-		      (write-region (point-min) (point-max) tmpfile)))
+		    (with-progress-reporter
+			v 3 (format "Decoding remote file %s with function %s"
+				    filename loc-dec)
+		      (funcall loc-dec (point-min) (point-max))
+		      ;; Unset `file-name-handler-alist'.  Otherwise,
+		      ;; epa-file gets confused.
+		      (let (file-name-handler-alist
+			    (coding-system-for-write 'binary))
+			(write-region (point-min) (point-max) tmpfile))))
 
 		;; If tramp-decoding-function is not defined for this
 		;; method, we invoke tramp-decoding-command instead.
@@ -4661,14 +4857,14 @@
 		  (let (file-name-handler-alist
 			(coding-system-for-write 'binary))
 		    (write-region (point-min) (point-max) tmpfile2))
-		  (tramp-message
-		   v 5 "Decoding remote file %s with command %s..."
-		   filename loc-dec)
-		  (unwind-protect
-		      (tramp-call-local-coding-command loc-dec tmpfile2 tmpfile)
-		    (delete-file tmpfile2))))
-
-	      (tramp-message v 5 "Decoding remote file %s...done" filename)
+		  (with-progress-reporter
+		      v 3 (format "Decoding remote file %s with command %s"
+				  filename loc-dec)
+		    (unwind-protect
+			(tramp-call-local-coding-command
+			 loc-dec tmpfile2 tmpfile)
+		      (delete-file tmpfile2)))))
+
 	      ;; Set proper permissions.
 	      (set-file-modes tmpfile (tramp-default-file-modes filename))
 	      ;; Set local user ownership.
@@ -4724,7 +4920,7 @@
   "Like `insert-file-contents' for Tramp files."
   (barf-if-buffer-read-only)
   (setq filename (expand-file-name filename))
-  (let (coding-system-used result local-copy remote-copy)
+  (let (result local-copy remote-copy)
     (with-parsed-tramp-file-name filename nil
       (unwind-protect
 	  (if (not (file-exists-p filename))
@@ -4795,27 +4991,16 @@
 		(setq tramp-temp-buffer-file-name local-copy)
 		(put 'tramp-temp-buffer-file-name 'permanent-local t))
 
-	      (tramp-message
-	       v 4 "Inserting local temp file `%s'..." local-copy)
-
-	      ;; We must ensure that `file-coding-system-alist'
-	      ;; matches `local-copy'.
-	      (let ((file-coding-system-alist
-		     (tramp-find-file-name-coding-system-alist
-		      filename local-copy)))
-		(setq result
-		      (insert-file-contents
-		       local-copy nil nil nil replace))
-		;; Now `last-coding-system-used' has right value.
-		;; Remember it.
-		(when (boundp 'last-coding-system-used)
-		  (setq coding-system-used
-			(symbol-value 'last-coding-system-used))))
-
-	      (tramp-message
-	       v 4 "Inserting local temp file `%s'...done" local-copy)
-	      (when (boundp 'last-coding-system-used)
-		(set 'last-coding-system-used coding-system-used))))
+	      (with-progress-reporter
+		  v 3 (format "Inserting local temp file `%s'" local-copy)
+		;; We must ensure that `file-coding-system-alist'
+		;; matches `local-copy'.
+		(let ((file-coding-system-alist
+		       (tramp-find-file-name-coding-system-alist
+			filename local-copy)))
+		  (setq result
+			(insert-file-contents
+			 local-copy nil nil nil replace))))))
 
 	;; Save exit.
 	(progn
@@ -4862,9 +5047,9 @@
   "Like `find-backup-file-name' for Tramp files."
   (with-parsed-tramp-file-name filename nil
     ;; We set both variables. It doesn't matter whether it is
-    ;; Emacs or XEmacs
+    ;; Emacs or XEmacs.
     (let ((backup-directory-alist
-	   ;; Emacs case
+	   ;; Emacs case.
 	   (when (boundp 'backup-directory-alist)
 	     (if (symbol-value 'tramp-backup-directory-alist)
 		 (mapcar
@@ -4880,7 +5065,7 @@
 	       (symbol-value 'backup-directory-alist))))
 
 	  (bkup-backup-directory-info
-	   ;; XEmacs case
+	   ;; XEmacs case.
 	   (when (boundp 'bkup-backup-directory-info)
 	     (if (symbol-value 'tramp-bkup-backup-directory-info)
 		 (mapcar
@@ -4984,12 +5169,10 @@
 	   'write-region
 	   (list start end localname append 'no-message lockname confirm))
 
-	(let ((rem-dec (tramp-get-remote-coding v "remote-decoding"))
-	      (loc-enc (tramp-get-local-coding v "local-encoding"))
-	      (modes (save-excursion (tramp-default-file-modes filename)))
+	(let ((modes (save-excursion (tramp-default-file-modes filename)))
 	      ;; We use this to save the value of
-	      ;; `last-coding-system-used' after writing the tmp file.
-	      ;; At the end of the function, we set
+	      ;; `last-coding-system-used' after writing the tmp
+	      ;; file.  At the end of the function, we set
 	      ;; `last-coding-system-used' to this saved value.  This
 	      ;; way, any intermediary coding systems used while
 	      ;; talking to the remote shell or suchlike won't hose
@@ -5012,7 +5195,8 @@
 	  ;; file.  We call `set-visited-file-modtime' ourselves later
 	  ;; on.  We must ensure that `file-coding-system-alist'
 	  ;; matches `tmpfile'.
-	  (let ((file-coding-system-alist
+	  (let (file-name-handler-alist
+		(file-coding-system-alist
 		 (tramp-find-file-name-coding-system-alist filename tmpfile)))
 	    (condition-case err
 		(tramp-run-real-handler
@@ -5044,124 +5228,126 @@
 	  ;; specified.  However, if the method _also_ specifies an
 	  ;; encoding function, then that is used for encoding the
 	  ;; contents of the tmp file.
-	  (cond
-	   ;; `copy-file' handles direct copy and out-of-band methods.
-	   ((or (tramp-local-host-p v)
-		(tramp-method-out-of-band-p
-		 v (nth 7 (file-attributes tmpfile))))
-	    (if (and (not (stringp start))
-		     (= (or end (point-max)) (point-max))
-		     (= (or start (point-min)) (point-min))
-		     (tramp-get-method-parameter
-		      method 'tramp-copy-keep-tmpfile))
-		(progn
-		  (setq tramp-temp-buffer-file-name tmpfile)
-		  (condition-case err
-		      ;; We keep the local file for performance
-		      ;; reasons, useful for "rsync".
-		      (copy-file tmpfile filename t)
-		    ((error quit)
-		     (setq tramp-temp-buffer-file-name nil)
-		     (delete-file tmpfile)
-		     (signal (car err) (cdr err)))))
-	      (setq tramp-temp-buffer-file-name nil)
-	      ;; Don't rename, in order to keep context in SELinux.
+	  (let* ((size (nth 7 (file-attributes tmpfile)))
+		 (rem-dec (tramp-get-inline-coding v "remote-decoding" size))
+		 (loc-enc (tramp-get-inline-coding v "local-encoding" size)))
+	    (cond
+	     ;; `copy-file' handles direct copy and out-of-band methods.
+	     ((or (tramp-local-host-p v)
+		  (tramp-method-out-of-band-p v size))
+	      (if (and (not (stringp start))
+		       (= (or end (point-max)) (point-max))
+		       (= (or start (point-min)) (point-min))
+		       (tramp-get-method-parameter
+			method 'tramp-copy-keep-tmpfile))
+		  (progn
+		    (setq tramp-temp-buffer-file-name tmpfile)
+		    (condition-case err
+			;; We keep the local file for performance
+			;; reasons, useful for "rsync".
+			(copy-file tmpfile filename t)
+		      ((error quit)
+		       (setq tramp-temp-buffer-file-name nil)
+		       (delete-file tmpfile)
+		       (signal (car err) (cdr err)))))
+		(setq tramp-temp-buffer-file-name nil)
+		;; Don't rename, in order to keep context in SELinux.
+		(unwind-protect
+		    (copy-file tmpfile filename t)
+		  (delete-file tmpfile))))
+
+	     ;; Use inline file transfer.
+	     (rem-dec
+	      ;; Encode tmpfile.
 	      (unwind-protect
-		  (copy-file tmpfile filename t)
-		(delete-file tmpfile))))
-
-	   ;; Use inline file transfer.
-	   (rem-dec
-	    ;; Encode tmpfile.
-	    (tramp-message v 5 "Encoding region...")
-	    (unwind-protect
-		(with-temp-buffer
-		  ;; Use encoding function or command.
-		  (if (and (symbolp loc-enc) (fboundp loc-enc))
-		      (progn
-			(tramp-message
-			 v 5 "Encoding region using function `%s'..."
-			 (symbol-name loc-enc))
-			(let ((coding-system-for-read 'binary))
-			  (insert-file-contents-literally tmpfile))
-			;; The following `let' is a workaround for the
-			;; base64.el that comes with pgnus-0.84.  If
-			;; both of the following conditions are
-			;; satisfied, it tries to write to a local
-			;; file in default-directory, but at this
-			;; point, default-directory is remote.
-			;; (`call-process-region' can't write to
-			;; remote files, it seems.)  The file in
-			;; question is a tmp file anyway.
-			(let ((default-directory
-				(tramp-compat-temporary-file-directory)))
-			  (funcall loc-enc (point-min) (point-max))))
-
-		    (tramp-message
-		     v 5 "Encoding region using command `%s'..." loc-enc)
-		    (unless (equal 0 (tramp-call-local-coding-command
-				      loc-enc tmpfile t))
-		      (tramp-error
-		       v 'file-error
-		       "Cannot write to `%s', local encoding command `%s' failed"
-		       filename loc-enc)))
-
-		  ;; Send buffer into remote decoding command which
-		  ;; writes to remote file.  Because this happens on
-		  ;; the remote host, we cannot use the function.
-		  (goto-char (point-max))
-		  (unless (bolp) (newline))
-		  (tramp-message
-		   v 5 "Decoding region into remote file %s..." filename)
-		  (tramp-send-command
-		   v
-		   (format
-		    "%s >%s <<'EOF'\n%sEOF"
-		    rem-dec
-		    (tramp-shell-quote-argument localname)
-		    (buffer-string)))
-		  (tramp-barf-unless-okay
-		   v nil
-		   "Couldn't write region to `%s', decode using `%s' failed"
-		   filename rem-dec)
-		  ;; When `file-precious-flag' is set, the region is
-		  ;; written to a temporary file.  Check that the
-		  ;; checksum is equal to that from the local tmpfile.
-		  (when file-precious-flag
-		    (erase-buffer)
-		    (and
-		     ;; cksum runs locally, if possible.
-		     (zerop (tramp-local-call-process "cksum" tmpfile t))
-		     ;; cksum runs remotely.
-		     (zerop
-		      (tramp-send-command-and-check
+		  (with-temp-buffer
+		    (set-buffer-multibyte nil)
+		    ;; Use encoding function or command.
+		    (if (functionp loc-enc)
+			(with-progress-reporter
+			    v 3 (format "Encoding region using function `%s'"
+					loc-enc)
+			  (let ((coding-system-for-read 'binary))
+			    (insert-file-contents-literally tmpfile))
+			  ;; The following `let' is a workaround for the
+			  ;; base64.el that comes with pgnus-0.84.  If
+			  ;; both of the following conditions are
+			  ;; satisfied, it tries to write to a local
+			  ;; file in default-directory, but at this
+			  ;; point, default-directory is remote.
+			  ;; (`call-process-region' can't write to
+			  ;; remote files, it seems.)  The file in
+			  ;; question is a tmp file anyway.
+			  (let ((default-directory
+				  (tramp-compat-temporary-file-directory)))
+			    (funcall loc-enc (point-min) (point-max))))
+
+		      (with-progress-reporter
+			  v 3 (format "Encoding region using command `%s'"
+				      loc-enc)
+			(unless (zerop (tramp-call-local-coding-command
+					loc-enc tmpfile t))
+			  (tramp-error
+			   v 'file-error
+			   (concat "Cannot write to `%s', "
+				   "local encoding command `%s' failed")
+			   filename loc-enc))))
+
+		    ;; Send buffer into remote decoding command which
+		    ;; writes to remote file.  Because this happens on
+		    ;; the remote host, we cannot use the function.
+		    (with-progress-reporter
+			v 3
+			(format "Decoding region into remote file %s" filename)
+		      (goto-char (point-max))
+		      (unless (bolp) (newline))
+		      (tramp-send-command
 		       v
 		       (format
-			"cksum <%s" (tramp-shell-quote-argument localname))))
-		     ;; ... they are different.
-		     (not
-		      (string-equal
-		       (buffer-string)
-		       (with-current-buffer (tramp-get-buffer v)
-			 (buffer-string))))
-		     (tramp-error
-		      v 'file-error
-		      (concat "Couldn't write region to `%s',"
-			      " decode using `%s' failed")
-		      filename rem-dec)))
-		  (tramp-message
-		   v 5 "Decoding region into remote file %s...done" filename))
-
-	      ;; Save exit.
-	      (delete-file tmpfile)))
-
-	   ;; That's not expected.
-	   (t
-	    (tramp-error
-	     v 'file-error
-	     (concat "Method `%s' should specify both encoding and "
-		     "decoding command or an rcp program")
-	     method)))
+			(concat rem-dec " <<'EOF'\n%sEOF")
+			(tramp-shell-quote-argument localname)
+			(buffer-string)))
+		      (tramp-barf-unless-okay
+		       v nil
+		       "Couldn't write region to `%s', decode using `%s' failed"
+		       filename rem-dec)
+		      ;; When `file-precious-flag' is set, the region is
+		      ;; written to a temporary file.  Check that the
+		      ;; checksum is equal to that from the local tmpfile.
+		      (when file-precious-flag
+			(erase-buffer)
+			(and
+			 ;; cksum runs locally, if possible.
+			 (zerop (tramp-local-call-process "cksum" tmpfile t))
+			 ;; cksum runs remotely.
+			 (zerop
+			  (tramp-send-command-and-check
+			   v
+			   (format
+			    "cksum <%s"
+			    (tramp-shell-quote-argument localname))))
+			 ;; ... they are different.
+			 (not
+			  (string-equal
+			   (buffer-string)
+			   (with-current-buffer (tramp-get-buffer v)
+			     (buffer-string))))
+			 (tramp-error
+			  v 'file-error
+			  (concat "Couldn't write region to `%s',"
+				  " decode using `%s' failed")
+			  filename rem-dec)))))
+
+		;; Save exit.
+		(delete-file tmpfile)))
+
+	     ;; That's not expected.
+	     (t
+	      (tramp-error
+	       v 'file-error
+	       (concat "Method `%s' should specify both encoding and "
+		       "decoding command or an rcp program")
+	       method))))
 
 	  ;; Make `last-coding-system-used' have the right value.
 	  (when coding-system-used
@@ -5210,46 +5396,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 <<'EOF'\n%s\nEOF\n"
+		   (mapconcat 'tramp-shell-quote-argument
+			      tramp-vc-registered-file-names
+			      "\n"))))
+
+	      (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)
@@ -5294,7 +5484,7 @@
   "Return file name related to OPERATION file primitive.
 ARGS are the arguments OPERATION has been called with."
   (cond
-   ; FILE resp DIRECTORY
+   ;; FILE resp DIRECTORY.
    ((member operation
 	    (list 'access-file 'byte-compiler-base-file-name 'delete-directory
 		  'delete-file 'diff-latest-backup-file 'directory-file-name
@@ -5312,9 +5502,11 @@
 		  'load 'make-directory 'make-directory-internal
 		  'set-file-modes 'substitute-in-file-name
 		  'unhandled-file-name-directory 'vc-registered
-		  ; Emacs 22 only
+		  ;; Emacs 22+ only.
 		  'set-file-times
-		  ; XEmacs only
+		  ;; Emacs 24+ only.
+		  'file-selinux-context 'set-file-selinux-context
+		  ;; XEmacs only.
 		  'abbreviate-file-name 'create-file-buffer
 		  'dired-file-modtime 'dired-make-compressed-filename
 		  'dired-recursive-delete-directory 'dired-set-file-modtime
@@ -5324,14 +5516,14 @@
     (if (file-name-absolute-p (nth 0 args))
 	(nth 0 args)
       (expand-file-name (nth 0 args))))
-   ; FILE DIRECTORY resp FILE1 FILE2
+   ;; FILE DIRECTORY resp FILE1 FILE2.
    ((member operation
 	    (list 'add-name-to-file 'copy-file 'expand-file-name
 		  'file-name-all-completions 'file-name-completion
 		  'file-newer-than-file-p 'make-symbolic-link 'rename-file
-		  ; Emacs 23 only
+		  ;; Emacs 23+ only.
 		  'copy-directory
-		  ; XEmacs only
+		  ;; XEmacs only.
 		  'dired-make-relative-symlink
 		  'vm-imap-move-mail 'vm-pop-move-mail 'vm-spool-move-mail))
     (save-match-data
@@ -5339,39 +5531,40 @@
        ((string-match tramp-file-name-regexp (nth 0 args)) (nth 0 args))
        ((string-match tramp-file-name-regexp (nth 1 args)) (nth 1 args))
        (t (buffer-file-name (current-buffer))))))
-   ; START END FILE
+   ;; START END FILE.
    ((eq operation 'write-region)
     (nth 2 args))
-   ; BUF
+   ;; BUFFER.
    ((member operation
 	    (list 'set-visited-file-modtime 'verify-visited-file-modtime
-                  ; since Emacs 22 only
+                  ;; Emacs 22+ only.
 		  'make-auto-save-file-name
-	          ; XEmacs only
+	          ;; XEmacs only.
 		  'backup-buffer))
     (buffer-file-name
      (if (bufferp (nth 0 args)) (nth 0 args) (current-buffer))))
-   ; COMMAND
+   ;; COMMAND.
    ((member operation
-	    (list ; not in Emacs 23
+	    (list ;; not in Emacs 23+.
 	          'dired-call-process
-                  ; Emacs only
+                  ;; Emacs only.
 		  'shell-command
-                  ; since Emacs 22 only
+                  ;; Emacs 22+ only.
                   'process-file
-                  ; since Emacs 23 only
+                  ;; Emacs 23+ only.
                   'start-file-process
-	          ; XEmacs only
+	          ;; XEmacs only.
 		  'dired-print-file 'dired-shell-call-process
-		  ; nowhere yet
-		  'executable-find 'start-process 'call-process))
+		  ;; nowhere yet.
+		  'executable-find 'start-process
+		  'call-process 'call-process-region))
     default-directory)
-   ; unknown file primitive
+   ;; Unknown file primitive.
    (t (error "unknown file I/O primitive: %s" operation))))
 
 (defun tramp-find-foreign-file-name-handler (filename)
   "Return foreign file name handler if exists."
-  (when (and (stringp filename) (tramp-tramp-file-p filename))
+  (when (tramp-tramp-file-p filename)
     (let ((v (tramp-dissect-file-name filename t))
 	  (handler tramp-foreign-file-name-handler-alist)
 	  elt res)
@@ -5403,19 +5596,40 @@
 	       (completion (tramp-completion-mode-p))
 	       (foreign (tramp-find-foreign-file-name-handler filename)))
 	  (with-parsed-tramp-file-name filename nil
-	    (cond
-	     ;; When we are in completion mode, some operations
-	     ;; shouldn't be handled by backend.
-	     ((and completion (zerop (length localname))
-		   (memq operation '(file-exists-p file-directory-p)))
-	      t)
-	     ((and completion (zerop (length localname))
-		   (memq operation '(file-name-as-directory)))
-	      filename)
-	     ;; Call the backend function.
-	     (foreign (apply foreign operation args))
-	     ;; Nothing to do for us.
-	     (t (tramp-run-real-handler operation args))))))
+	    ;; Call the backend function.
+	    (if foreign
+		(condition-case err
+		    (apply foreign operation args)
+
+		  ;; Trace that somebody has interrupted the
+		  ;; operation.
+		  (quit
+		   (let (tramp-message-show-message)
+		     (tramp-message
+		      v 1 "Interrupt received in operation %s"
+		      (append (list operation) args)))
+		   ;; Propagate the quit signal.
+		   (signal (car err) (cdr err)))
+
+		  ;; When we are in completion mode, some failed
+		  ;; operations shall return at least a default value
+		  ;; in order to give the user a chance to correct the
+		  ;; file name in the minibuffer.
+		  (error
+		   (cond
+		    ((and completion (zerop (length localname))
+			  (memq operation '(file-exists-p file-directory-p)))
+		     t)
+		    ((and completion (zerop (length localname))
+			  (memq operation
+				'(expand-file-name file-name-as-directory)))
+		     filename)
+		    ;; Propagate the error.
+		    (t (signal (car err) (cdr err))))))
+
+	      ;; Nothing to do for us.
+	      (tramp-run-real-handler operation args)))))
+
     ;; When `tramp-mode' is not enabled, we don't do anything.
     (tramp-run-real-handler operation args)))
 
@@ -5505,8 +5719,11 @@
          ;; disable this part of the completion, unless the user implicitly
          ;; indicated his interest in using a fancier completion system.
          (or (eq tramp-syntax 'sep)
-             (featurep 'tramp) ; If it's loaded, we may as well use it.
-             (and (boundp 'partial-completion-mode) partial-completion-mode)
+             (featurep 'tramp) ;; If it's loaded, we may as well use it.
+	     ;; `partial-completion-mode' does not exist in XEmacs.
+	     ;; It is obsoleted with Emacs 24.1.
+             (and (boundp 'partial-completion-mode)
+		  (symbol-value 'partial-completion-mode))
              ;; FIXME: These may have been loaded even if the user never
              ;; intended to use them.
              (featurep 'ido)
@@ -5579,9 +5796,10 @@
 ;; overwriting this check in such cases. Or we change Tramp file name
 ;; syntax in order to avoid ambiguities, like in XEmacs ...
 (defun tramp-completion-mode-p ()
-  "Checks whether method / user name / host name completion is active."
+  "Check, whether method / user name / host name completion is active."
   (or
-   ;; Signal from outside.
+   ;; Signal from outside.  `non-essential' has been introduced in Emacs 24.
+   (and (boundp 'non-essential) (symbol-value 'non-essential))
    tramp-completion-mode
    ;; Emacs.
    (equal last-input-event 'tab)
@@ -5597,19 +5815,27 @@
 	;; `last-input-event' might be nil.
 	(not (null last-input-event))
 	;; `last-input-event' may have no character approximation.
-	(funcall (symbol-function 'event-to-character) last-input-event)
+	(tramp-compat-funcall 'event-to-character last-input-event)
 	(or
 	 ;; ?\t has event-modifier 'control.
 	 (equal
-	  (funcall (symbol-function 'event-to-character)
-		   last-input-event) ?\t)
+	  (tramp-compat-funcall 'event-to-character last-input-event) ?\t)
 	 (and (not (event-modifiers last-input-event))
 	      (or (equal
-		   (funcall (symbol-function 'event-to-character)
-			    last-input-event) ?\?)
+		   (tramp-compat-funcall 'event-to-character last-input-event)
+		   ?\?)
 		  (equal
-		   (funcall (symbol-function 'event-to-character)
-			    last-input-event) ?\ )))))))
+		   (tramp-compat-funcall 'event-to-character last-input-event)
+		   ?\ )))))))
+
+(defun tramp-connectable-p (filename)
+  "Check, whether it is possible to connect the remote host w/o side-effects.
+This is true, if either the remote host is already connected, or if we are
+not in completion mode."
+  (and (tramp-tramp-file-p filename)
+       (with-parsed-tramp-file-name filename nil
+	 (or (get-buffer (tramp-buffer-name v))
+	     (not (tramp-completion-mode-p))))))
 
 ;; Method, host name and user name completion.
 ;; `tramp-completion-dissect-file-name' returns a list of
@@ -5674,8 +5900,10 @@
     (append
      result1
      (condition-case nil
-	 (tramp-completion-run-real-handler
-	  'file-name-all-completions (list filename directory))
+	 (apply (if (tramp-connectable-p fullname)
+		    'tramp-completion-run-real-handler
+		  'tramp-run-real-handler)
+		'file-name-all-completions (list (list filename directory)))
        (error nil)))))
 
 ;; Method, host name and user name completion for a file.
@@ -5686,7 +5914,8 @@
   (try-completion
    filename
    (mapcar 'list (file-name-all-completions filename directory))
-   (when predicate
+   (when (and predicate
+	      (tramp-connectable-p (expand-file-name filename directory)))
      (lambda (x) (funcall predicate (expand-file-name (car x) directory))))))
 
 ;; I misuse a little bit the tramp-file-name structure in order to handle
@@ -6141,14 +6370,13 @@
   (let* ((p (tramp-get-connection-process vec))
 	 (scripts (tramp-get-connection-property p "scripts" nil)))
     (unless (member name scripts)
-      (tramp-message vec 5 "Sending script `%s'..." name)
-      ;; The script could contain a call of Perl.  This is masked with `%s'.
-      (tramp-send-command-and-check
-       vec
-       (format "%s () {\n%s\n}" name
-	       (format script (tramp-get-remote-perl vec))))
-      (tramp-set-connection-property p "scripts" (cons name scripts))
-      (tramp-message vec 5 "Sending script `%s'...done." name))))
+      (with-progress-reporter vec 5 (format "Sending script `%s'" name)
+	;; The script could contain a call of Perl.  This is masked with `%s'.
+	(tramp-send-command-and-check
+	 vec
+	 (format "%s () {\n%s\n}" name
+		 (format script (tramp-get-remote-perl vec))))
+	(tramp-set-connection-property p "scripts" (cons name scripts))))))
 
 (defun tramp-set-auto-save ()
   (when (and ;; ange-ftp has its own auto-save mechanism
@@ -6256,22 +6484,24 @@
 	(format "*debug tramp/%s %s@%s*" method user host)
       (format "*debug tramp/%s %s*" method host))))
 
+(defconst tramp-debug-outline-regexp
+  "[0-9]+:[0-9]+:[0-9]+\\.[0-9]+ [a-z0-9-]+ (\\([0-9]+\\)) #")
+
 (defun tramp-get-debug-buffer (vec)
   "Get the debug buffer for VEC."
   (with-current-buffer
       (get-buffer-create (tramp-debug-buffer-name vec))
     (when (bobp)
       (setq buffer-undo-list t)
-      ;; Activate outline-mode.  This runs `text-mode-hook' and
+      ;; Activate `outline-mode'.  This runs `text-mode-hook' and
       ;; `outline-mode-hook'.  We must prevent that local processes
-      ;; die.  Yes: I've seen `flyspell-mode', which starts "ispell"
-      ;; ...
-      (let ((default-directory (tramp-compat-temporary-file-directory)))
+      ;; die.  Yes: I've seen `flyspell-mode', which starts "ispell".
+      ;; Furthermore, `outline-regexp' must have the correct value
+      ;; already, because it is used by `font-lock-compile-keywords'.
+      (let ((default-directory (tramp-compat-temporary-file-directory))
+	    (outline-regexp tramp-debug-outline-regexp))
 	(outline-mode))
-      (set (make-local-variable 'outline-regexp)
-	   "[0-9]+:[0-9]+:[0-9]+\\.[0-9]+ [a-z0-9-]+ (\\([0-9]+\\)) #")
-;      (set (make-local-variable 'outline-regexp)
-;	   "[a-z.-]+:[0-9]+: [a-z0-9-]+ (\\([0-9]+\\)) #")
+      (set (make-local-variable 'outline-regexp) tramp-debug-outline-regexp)
       (set (make-local-variable 'outline-level) 'tramp-outline-level))
     (current-buffer)))
 
@@ -6306,7 +6536,7 @@
 	    (setq result (concat "\\" progname))))
       (unless result
 	(when ignore-tilde
-	  ;; Remove all ~/foo directories from dirlist.  In Emacs 20,
+	  ;; Remove all ~/foo directories from dirlist.  In XEmacs,
 	  ;; `remove' is in CL, and we want to avoid CL dependencies.
 	  (let (newdl d)
 	    (while dirlist
@@ -6395,7 +6625,29 @@
        vec 'file-error "Couldn't find command to check if file exists"))
     result))
 
-;; CCC test ksh or bash found for tilde expansion?
+(defun tramp-open-shell (vec shell)
+  "Opens shell SHELL."
+  (with-progress-reporter vec 5 (format "Opening remote shell `%s'" shell)
+    ;; Find arguments for this shell.
+    (let ((tramp-end-of-output tramp-initial-end-of-output)
+	  (alist tramp-sh-extra-args)
+	  item extra-args)
+      (while (and alist (null extra-args))
+	(setq item (pop alist))
+	(when (string-match (car item) shell)
+	  (setq extra-args (cdr item))))
+      (when extra-args (setq shell (concat shell " " extra-args)))
+      (tramp-send-command
+       vec (format "exec env ENV='' PROMPT_COMMAND='' PS1=%s PS2='' PS3='' %s"
+		   (shell-quote-argument tramp-end-of-output) shell)
+       t))
+    ;; Setting prompts.
+    (tramp-send-command
+     vec (format "PS1=%s" (shell-quote-argument tramp-end-of-output)) t)
+    (tramp-send-command vec "PS2=''" t)
+    (tramp-send-command vec "PS3=''" t)
+    (tramp-send-command vec "PROMPT_COMMAND=''" t)))
+
 (defun tramp-find-shell (vec)
   "Opens a shell on the remote host which groks tilde expansion."
   (unless (tramp-get-connection-property vec "remote-shell" nil)
@@ -6416,39 +6668,16 @@
 	    (tramp-error
 	     vec 'file-error
 	     "Couldn't find a shell which groks tilde expansion"))
-	  ;; Find arguments for this shell.
-	  (let ((alist tramp-sh-extra-args)
-		item extra-args)
-	    (while (and alist (null extra-args))
-	      (setq item (pop alist))
-	      (when (string-match (car item) shell)
-		(setq extra-args (cdr item))))
-	    (when extra-args (setq shell (concat shell " " extra-args))))
 	  (tramp-message
-	   vec 5 "Starting remote shell `%s' for tilde expansion..." shell)
-	  (let ((tramp-end-of-output tramp-initial-end-of-output))
-	    (tramp-send-command
-	     vec
-	     (format "PROMPT_COMMAND='' PS1=%s PS2='' PS3='' exec %s"
-		     (shell-quote-argument tramp-end-of-output) shell)
-	     t))
-	  ;; Setting prompts.
-	  (tramp-message vec 5 "Setting remote shell prompt...")
-	  (tramp-send-command
-	   vec (format "PS1=%s" (shell-quote-argument tramp-end-of-output)) t)
-	  (tramp-send-command vec "PS2=''" t)
-	  (tramp-send-command vec "PS3=''" t)
-	  (tramp-send-command vec "PROMPT_COMMAND=''" t)
-	  (tramp-message vec 5 "Setting remote shell prompt...done"))
+	   vec 5 "Starting remote shell `%s' for tilde expansion" shell)
+	  (tramp-open-shell vec shell))
 
 	 (t (tramp-message
 	     vec 5 "Remote `%s' groks tilde expansion, good"
-	     (tramp-get-method-parameter
-	      (tramp-file-name-method vec) 'tramp-remote-sh))
-	    (tramp-set-connection-property
-	     vec "remote-shell"
-	     (tramp-get-method-parameter
-	      (tramp-file-name-method vec) 'tramp-remote-sh))))))))
+	     (tramp-set-connection-property
+	      vec "remote-shell"
+	      (tramp-get-method-parameter
+	       (tramp-file-name-method vec) 'tramp-remote-sh)))))))))
 
 ;; ------------------------------------------------------------
 ;; -- Functions for establishing connection --
@@ -6474,8 +6703,10 @@
   "Query the user for a password."
   (with-current-buffer (process-buffer proc)
     (tramp-check-for-regexp proc tramp-password-prompt-regexp)
-    (tramp-message vec 3 "Sending %s" (match-string 1)))
-  (tramp-enter-password proc))
+    (tramp-message vec 3 "Sending %s" (match-string 1))
+    (tramp-enter-password proc)
+    ;; Hide password prompt.
+    (narrow-to-region (point-max) (point-max))))
 
 (defun tramp-action-succeed (proc vec)
   "Signal success in finding shell prompt."
@@ -6523,12 +6754,12 @@
   (tramp-send-string vec tramp-terminal-type))
 
 (defun tramp-action-process-alive (proc vec)
-  "Check whether a process has finished."
+  "Check, whether a process has finished."
   (unless (memq (process-status proc) '(run open))
     (throw 'tramp-action 'process-died)))
 
 (defun tramp-action-out-of-band (proc vec)
-  "Check whether an out-of-band copy has finished."
+  "Check, whether an out-of-band copy has finished."
   (cond ((and (memq (process-status proc) '(stop exit))
 	      (zerop (process-exit-status proc)))
 	 (tramp-message	vec 3 "Process has finished.")
@@ -6572,27 +6803,30 @@
 
 (defun tramp-process-actions (proc vec actions &optional timeout)
   "Perform actions until success or TIMEOUT."
-  ;; Enable auth-source and password-cache.
-  (tramp-set-connection-property vec "first-password-request" t)
-  (let (exit)
-    (while (not exit)
-      (tramp-message proc 3 "Waiting for prompts from remote shell")
-      (setq exit
-	    (catch 'tramp-action
-	      (if timeout
-		  (with-timeout (timeout)
-		    (tramp-process-one-action proc vec actions))
-		(tramp-process-one-action proc vec actions)))))
-    (with-current-buffer (tramp-get-connection-buffer vec)
-      (tramp-message vec 6 "\n%s" (buffer-string)))
-    (unless (eq exit 'ok)
-      (tramp-clear-passwd vec)
-      (tramp-error-with-buffer
-       nil vec 'file-error
-       (cond
-	((eq exit 'permission-denied) "Permission denied")
-	((eq exit 'process-died) "Process died")
-	(t "Login failed"))))))
+  ;; Preserve message for `progress-reporter'.
+  (with-temp-message ""
+    ;; Enable auth-source and password-cache.
+    (tramp-set-connection-property vec "first-password-request" t)
+    (let (exit)
+      (while (not exit)
+	(tramp-message proc 3 "Waiting for prompts from remote shell")
+	(setq exit
+	      (catch 'tramp-action
+		(if timeout
+		    (with-timeout (timeout)
+		      (tramp-process-one-action proc vec actions))
+		  (tramp-process-one-action proc vec actions)))))
+      (with-current-buffer (tramp-get-connection-buffer vec)
+	(widen)
+	(tramp-message vec 6 "\n%s" (buffer-string)))
+      (unless (eq exit 'ok)
+	(tramp-clear-passwd vec)
+	(tramp-error-with-buffer
+	 nil vec 'file-error
+	 (cond
+	  ((eq exit 'permission-denied) "Permission denied")
+	  ((eq exit 'process-died) "Process died")
+	  (t "Login failed")))))))
 
 ;; Utility functions.
 
@@ -6610,7 +6844,7 @@
     (tramp-message proc 10 "\n%s" (buffer-string))))
 
 (defun tramp-check-for-regexp (proc regexp)
-  "Check whether REGEXP is contained in process buffer of PROC.
+  "Check, whether REGEXP is contained in process buffer of PROC.
 Erase echoed commands if exists."
   (with-current-buffer (process-buffer proc)
     (goto-char (point-min))
@@ -6623,17 +6857,18 @@
 	  ;; Discard echo from remote output.
 	  (tramp-set-connection-property proc "check-remote-echo" nil)
 	  (tramp-message proc 5 "echo-mark found")
-	  (forward-line)
+	  (forward-line 1)
 	  (delete-region begin (point))
 	  (goto-char (point-min)))))
 
     (when (or (not (tramp-get-connection-property proc "check-remote-echo" nil))
 	      ;; Sometimes, the echo string is suppressed on the remote side.
 	      (not (string-equal
-		    (substring-no-properties
-		     tramp-echo-mark-marker
+		    (tramp-compat-funcall
+		     'substring-no-properties tramp-echo-mark-marker
 		     0 (min tramp-echo-mark-marker-length (1- (point-max))))
-		    (buffer-substring-no-properties
+		    (tramp-compat-funcall
+		     'buffer-substring-no-properties
 		     1 (min (1+ tramp-echo-mark-marker-length) (point-max))))))
       ;; No echo to be handled, now we can look for the regexp.
       (goto-char (point-min))
@@ -6719,14 +6954,9 @@
     ;; way, we avoid the startup file clobbering $PS1.  $PROMP_COMMAND
     ;; is another way to set the prompt in /bin/bash, it must be
     ;; discarded as well.
-    (tramp-send-command
+    (tramp-open-shell
      vec
-     (format
-      "exec env ENV='' PROMPT_COMMAND='' PS1=%s PS2='' PS3='' %s"
-      (shell-quote-argument tramp-end-of-output)
-      (tramp-get-method-parameter
-       (tramp-file-name-method vec) 'tramp-remote-sh))
-     t)
+     (tramp-get-method-parameter (tramp-file-name-method vec) 'tramp-remote-sh))
 
     ;; Disable echo.
     (tramp-message vec 5 "Setting up remote shell environment")
@@ -6760,7 +6990,7 @@
     (if (featurep 'mule)
 	;; Use MULE to select the right EOL convention for communicating
 	;; with the process.
-	(let* ((cs (or (funcall (symbol-function 'process-coding-system) proc)
+	(let* ((cs (or (tramp-compat-funcall 'process-coding-system proc)
 		       (cons 'undecided 'undecided)))
 	       cs-decode cs-encode)
 	  (when (symbolp cs) (setq cs (cons cs cs)))
@@ -6773,8 +7003,8 @@
 	  (when (search-forward "\r" nil t)
 	    (setq cs-decode (tramp-coding-system-change-eol-conversion
 			     cs-decode 'dos)))
-	  (funcall (symbol-function 'set-buffer-process-coding-system)
-		   cs-decode cs-encode)
+	  (tramp-compat-funcall
+	   'set-buffer-process-coding-system cs-decode cs-encode)
 	  (tramp-message
 	   vec 5 "Setting coding system to `%s' and `%s'" cs-decode cs-encode))
       ;; Look for ^M and do something useful if found.
@@ -6784,7 +7014,7 @@
 	;; stty, instead.
 	(tramp-send-command vec "stty -onlcr" t))))
   ;; Dump stty settings in the traces.
-  (when (>= tramp-verbose 10)
+  (when (>= tramp-verbose 9)
     (tramp-send-command vec "stty -a" t))
   (tramp-send-command vec "set +o vi +o emacs" t)
 
@@ -6800,10 +7030,10 @@
 	  (tramp-send-command-and-read vec "echo \\\"`uname -sr`\\\""))))
     (when (and (stringp old-uname) (not (string-equal old-uname new-uname)))
       (with-current-buffer (tramp-get-debug-buffer vec)
-	;; Keep the debug buffer
+	;; Keep the debug buffer.
 	(rename-buffer
 	 (generate-new-buffer-name tramp-temp-buffer-name) 'unique)
-	(funcall (symbol-function 'tramp-cleanup-connection) vec)
+	(tramp-compat-funcall 'tramp-cleanup-connection vec)
 	(if (= (point-min) (point-max))
 	    (kill-buffer nil)
 	  (rename-buffer (tramp-debug-buffer-name vec) 'unique))
@@ -6842,7 +7072,7 @@
   ;; "echo $?"  part if the "test" part has an error.  In particular,
   ;; the OpenSolaris /bin/sh is a problem.  There are also other
   ;; problems with /bin/sh of OpenSolaris, like redirection of stderr
-  ;; in in function declarations, or changing HISTFILE in place.
+  ;; in function declarations, or changing HISTFILE in place.
   ;; Therefore, OpenSolaris' /bin/sh is replaced by bash, when
   ;; detected.
   (tramp-find-shell vec)
@@ -6850,6 +7080,17 @@
   ;; Disable unexpected output.
   (tramp-send-command vec "mesg n; biff n" t)
 
+  ;; IRIX64 bash expands "!" even when in single quotes.  This
+  ;; destroys our shell functions, we must disable it.  See
+  ;; <http://stackoverflow.com/questions/3291692/irix-bash-shell-expands-expression-in-single-quotes-yet-shouldnt>.
+  (when (string-match "^IRIX64" (tramp-get-connection-property vec "uname" ""))
+    (tramp-send-command vec "set +H" t))
+
+  ;; Set `remote-tty' process property.
+  (ignore-errors
+    (let ((tty (tramp-send-command-and-read vec "echo \\\"`tty`\\\"")))
+      (unless (zerop (length tty)) (process-put proc 'remote-tty tty))))
+
   ;; Set the environment.
   (tramp-message vec 5 "Setting default environment")
 
@@ -6865,7 +7106,7 @@
       (setq env (cdr env)))
     (when unset
       (tramp-send-command
-       vec (format "unset %s" (mapconcat 'identity unset " "))))) t)
+       vec (format "unset %s" (mapconcat 'identity unset " ")) t))))
 
 ;; CCC: We should either implement a Perl version of base64 encoding
 ;; and decoding.  Then we just use that in the last item.  The other
@@ -6894,7 +7135,7 @@
   "List of local coding commands for inline transfer.
 Each item is a list that looks like this:
 
-\(FORMAT ENCODING DECODING)
+\(FORMAT ENCODING DECODING\)
 
 FORMAT is  symbol describing the encoding/decoding format.  It can be
 `b64' for base64 encoding, `uu' for uu encoding, or `pack' for simple packing.
@@ -6927,7 +7168,7 @@
   "List of remote coding commands for inline transfer.
 Each item is a list that looks like this:
 
-\(FORMAT ENCODING DECODING)
+\(FORMAT ENCODING DECODING\)
 
 FORMAT is  symbol describing the encoding/decoding format.  It can be
 `b64' for base64 encoding, `uu' for uu encoding, or `pack' for simple packing.
@@ -7063,6 +7304,64 @@
     (if (string-match "%s" cmd) (format cmd input) cmd)
     (if (stringp output) (concat "> " output) ""))))
 
+(defconst tramp-inline-compress-commands
+  '(("gzip" "gzip -d")
+    ("bzip2" "bzip2 -d")
+    ("compress" "compress -d"))
+  "List of compress and decompress commands for inline transfer.
+Each item is a list that looks like this:
+
+\(COMPRESS DECOMPRESS\)
+
+COMPRESS or DECOMPRESS are strings with the respective commands.")
+
+(defun tramp-find-inline-compress (vec)
+  "Find an inline transfer compress command that works.
+Goes through the list `tramp-inline-compress-commands'."
+  (save-excursion
+    (let ((commands tramp-inline-compress-commands)
+	  (magic "xyzzy")
+	  item compress decompress
+	  found)
+      (while (and commands (not found))
+	(catch 'next
+	  (setq item (pop commands)
+		compress (nth 0 item)
+		decompress (nth 1 item))
+	  (tramp-message
+	   vec 5
+	   "Checking local compress command `%s', `%s' for sanity"
+	   compress decompress)
+	  (unless (zerop (tramp-call-local-coding-command
+			  (format "echo %s | %s | %s"
+				  magic compress decompress) nil nil))
+	    (throw 'next nil))
+	  (tramp-message
+	   vec 5
+	   "Checking remote compress command `%s', `%s' for sanity"
+	   compress decompress)
+	  (unless (zerop (tramp-send-command-and-check
+			  vec (format "echo %s | %s | %s"
+				      magic compress decompress) t))
+	    (throw 'next nil))
+	  (setq found t)))
+
+      ;; Did we find something?
+      (if found
+	  (progn
+	    ;; Set connection properties.
+	    (tramp-message
+	     vec 5 "Using inline transfer compress command `%s'" compress)
+	    (tramp-set-connection-property vec "inline-compress" compress)
+	    (tramp-message
+	     vec 5 "Using inline transfer decompress command `%s'" decompress)
+	    (tramp-set-connection-property vec "inline-decompress" decompress))
+
+	(tramp-set-connection-property vec "inline-compress" nil)
+	(tramp-set-connection-property vec "inline-decompress" nil)
+	(tramp-message
+	 vec 2 "Couldn't find an inline transfer compress command")))))
+
 (defun tramp-compute-multi-hops (vec)
   "Expands VEC according to `tramp-default-proxies-alist'.
 Gateway hops are already opened."
@@ -7088,8 +7387,9 @@
 	  (setq proxy
 		(format-spec
 		 proxy
-		 `((?u . ,(or (tramp-file-name-user (car target-alist)) ""))
-		   (?h . ,(or (tramp-file-name-host (car target-alist)) "")))))
+		 (format-spec-make
+		  ?u (or (tramp-file-name-user (car target-alist)) "")
+		  ?h (or (tramp-file-name-host (car target-alist)) ""))))
 	  (with-parsed-tramp-file-name proxy l
 	    ;; Add the hop.
 	    (add-to-list 'target-alist l)
@@ -7127,7 +7427,7 @@
 	 'target-alist
 	 (vector
 	  (tramp-file-name-method hop) (tramp-file-name-user hop)
-	  (funcall (symbol-function 'tramp-gw-open-connection) vec gw hop) nil))
+	  (tramp-compat-funcall 'tramp-gw-open-connection vec gw hop) nil))
 	;; For the password prompt, we need the correct values.
 	;; Therefore, we must remember the gateway vector.  But we
 	;; cannot do it as connection property, because it shouldn't
@@ -7181,6 +7481,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
@@ -7214,127 +7515,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)
-	  (tramp-message vec 3 "Waiting 60s for local shell to come up...")
-	  (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)
+	     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))
+		     (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 async-args login-args)))
+
+		;; Add gateway arguments if necessary.
+		(when (and gw gw-args)
+		  (setq login-args (append gw-args login-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 `((?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.
@@ -7746,7 +8055,7 @@
 ;; data structure.
 
 (defun tramp-file-name-p (vec)
-  "Check whether VEC is a Tramp object."
+  "Check, whether VEC is a Tramp object."
   (and (vectorp vec) (= 4 (length vec))))
 
 (defun tramp-file-name-method (vec)
@@ -7877,7 +8186,7 @@
 	   localname))))))
 
 (defun tramp-equal-remote (file1 file2)
-  "Checks, whether the remote parts of FILE1 and FILE2 are identical.
+  "Check, whether the remote parts of FILE1 and FILE2 are identical.
 The check depends on method, user and host name of the files.  If
 one of the components is missing, the default values are used.
 The local file name parts of FILE1 and FILE2 are not taken into
@@ -7942,8 +8251,9 @@
    (tramp-get-method-parameter (tramp-file-name-method vec) 'tramp-copy-program)
    ;; Either the file size is large enough, or (in rare cases) there
    ;; does not exist a remote encoding.
-   (or (> size tramp-copy-size-limit)
-       (null (tramp-get-remote-coding vec "remote-encoding")))))
+   (or (null tramp-copy-size-limit)
+       (> size tramp-copy-size-limit)
+       (null (tramp-get-inline-coding vec "remote-encoding" size)))))
 
 (defun tramp-local-host-p (vec)
   "Return t if this points to the local host, nil otherwise."
@@ -7980,7 +8290,7 @@
 	  (tramp-get-connection-process vec)
 	vec)
       "remote-path"
-    (let* ((remote-path (tramp-compat-copy-tree tramp-remote-path))
+    (let* ((remote-path (copy-tree tramp-remote-path))
 	   (elt1 (memq 'tramp-default-remote-path remote-path))
 	   (elt2 (memq 'tramp-own-remote-path remote-path))
 	   (default-remote-path
@@ -8068,10 +8378,14 @@
 	     ;; Check parameters.  On busybox, "ls" output coloring is
 	     ;; enabled by default sometimes.  So we try to disable it
 	     ;; when possible.  $LS_COLORING is not supported there.
+	     ;; Some "ls" versions are sensible wrt the order of
+	     ;; arguments, they fail when "-al" is after the
+	     ;; "--color=never" argument (for example on FreeBSD).
 	     (when (zerop (tramp-send-command-and-check
 			   vec (format "%s -lnd /" result)))
 	       (when (zerop (tramp-send-command-and-check
-			     vec (format "%s --color=never /" result)))
+			     vec (format
+				  "%s --color=never -al /dev/null" result)))
 		 (setq result (concat result " --color=never")))
 	       (throw 'ls-found result))
 	     (setq dl (cdr dl))))))
@@ -8081,8 +8395,12 @@
   (save-match-data
     (with-connection-property vec "ls-dired"
       (tramp-message vec 5 "Checking, whether `ls --dired' works")
+      ;; Some "ls" versions are sensible wrt the order of arguments,
+      ;; they fail when "-al" is after the "--dired" argument (for
+      ;; example on FreeBSD).
       (zerop (tramp-send-command-and-check
-	      vec (format "%s --dired /" (tramp-get-ls-command vec)))))))
+	      vec (format "%s --dired -al /dev/null"
+			  (tramp-get-ls-command vec)))))))
 
 (defun tramp-get-test-command (vec)
   (with-connection-property vec "test"
@@ -8178,6 +8496,11 @@
 		     (error nil))))
 	result))))
 
+(defun tramp-get-remote-trash (vec)
+  (with-connection-property vec "trash"
+    (tramp-message vec 5 "Finding a suitable `trash' command")
+    (tramp-find-executable vec "trash" (tramp-get-remote-path vec))))
+
 (defun tramp-get-remote-id (vec)
   (with-connection-property vec "id"
     (tramp-message vec 5 "Finding POSIX `id' command")
@@ -8224,38 +8547,89 @@
   (nth 3 (tramp-compat-file-attributes "~/" id-format)))
 
 ;; Some predefined connection properties.
-(defun tramp-get-remote-coding (vec prop)
-  ;; Local coding handles properties like remote coding.  So we could
-  ;; call it without pain.
-  (let ((ret (tramp-get-local-coding vec prop)))
+(defun tramp-get-inline-compress (vec prop size)
+  "Return the compress command related to PROP.
+PROP is either `inline-compress' or `inline-decompress'. SIZE is
+the length of the file to be compressed.
+
+If no corresponding command is found, nil is returned."
+  (when (and (integerp tramp-inline-compress-start-size)
+	     (> size tramp-inline-compress-start-size))
+    (with-connection-property vec prop
+      (tramp-find-inline-compress vec)
+      (tramp-get-connection-property vec prop nil))))
+
+(defun tramp-get-inline-coding (vec prop size)
+  "Return the coding command related to PROP.
+PROP is either `remote-encoding', `remode-decoding',
+`local-encoding' or `local-decoding'.
+
+SIZE is the length of the file to be coded.  Depending on SIZE,
+compression might be applied.
+
+If no corresponding command is found, nil is returned.
+Otherwise, either a string is returned which contains a `%s' mark
+to be used for the respective input or output file; or a Lisp
+function cell is returned to be applied on a buffer."
+  (let ((coding
+	 (with-connection-property vec prop
+	   (tramp-find-inline-encoding vec)
+	   (tramp-get-connection-property vec prop nil)))
+	(prop1 (if (string-match "encoding" prop)
+		   "inline-compress" "inline-decompress"))
+	compress)
     ;; The connection property might have been cached.  So we must send
-    ;; the script - maybe.
-    (when (and ret (symbolp ret))
-      (let ((name (symbol-name ret)))
+    ;; the script to the remote side - maybe.
+    (when (and coding (symbolp coding) (string-match "remote" prop))
+      (let ((name (symbol-name coding)))
 	(while (string-match (regexp-quote "-") name)
 	  (setq name (replace-match "_" nil t name)))
-	(tramp-maybe-send-script vec (symbol-value ret) name)
-	(setq ret name)))
-    ;; Return the value.
-    ret))
-
-(defun tramp-get-local-coding (vec prop)
-  (or
-   (tramp-get-connection-property vec prop nil)
-   (progn
-     (tramp-find-inline-encoding vec)
-     (tramp-get-connection-property vec prop nil))))
+	(tramp-maybe-send-script vec (symbol-value coding) name)
+	(setq coding name)))
+    (when coding
+      ;; Check for the `compress' command.
+      (setq compress (tramp-get-inline-compress vec prop1 size))
+      ;; Return the value.
+      (cond
+       ((and compress (symbolp coding))
+	(if (string-match "decompress" prop1)
+	    `(lambda (beg end)
+	       (,coding beg end)
+	       (let ((coding-system-for-write 'binary)
+		     (coding-system-for-read 'binary))
+		 (apply
+		  'call-process-region (point-min) (point-max)
+		  (car (split-string ,compress)) t t nil
+		  (cdr (split-string ,compress)))))
+	  `(lambda (beg end)
+	     (let ((coding-system-for-write 'binary)
+		   (coding-system-for-read 'binary))
+	       (apply
+		'call-process-region beg end
+		(car (split-string ,compress)) t t nil
+		(cdr (split-string ,compress))))
+	     (,coding (point-min) (point-max)))))
+       ((symbolp coding)
+	coding)
+       ((and compress (string-match "decoding" prop))
+	(format "(%s | %s >%%s)" coding compress))
+       (compress
+	(format "(%s <%%s | %s)" compress coding))
+       ((string-match "decoding" prop)
+	(format "%s >%%s" coding))
+       (t
+	(format "%s <%%s" coding))))))
 
 (defun tramp-get-method-parameter (method param)
   "Return the method parameter PARAM.
-If the `tramp-methods' entry does not exist, return NIL."
+If the `tramp-methods' entry does not exist, return nil."
   (let ((entry (assoc param (assoc method tramp-methods))))
     (when entry (cadr entry))))
 
 ;; Auto saving to a special directory.
 
 (defun tramp-exists-file-name-handler (operation &rest args)
-  "Checks whether OPERATION runs a file name handler."
+  "Check, whether OPERATION runs a file name handler."
   ;; The file name handler is determined on base of either an
   ;; argument, `buffer-file-name', or `default-directory'.
   (condition-case nil
@@ -8279,7 +8653,7 @@
   (defadvice make-auto-save-file-name
     (around tramp-advice-make-auto-save-file-name () activate)
     "Invoke `tramp-handle-make-auto-save-file-name' for Tramp files."
-    (if (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name)))
+    (if (tramp-tramp-file-p (buffer-file-name))
 	;; We cannot call `tramp-handle-make-auto-save-file-name'
 	;; directly, because this would bypass the locking mechanism.
 	(setq ad-return-value
@@ -8293,14 +8667,13 @@
       'around 'tramp-advice-make-auto-save-file-name)
      (ad-activate 'make-auto-save-file-name))))
 
-;; In Emacs < 22 and XEmacs < 21.5 autosaved remote files have
-;; permission 0666 minus umask. This is a security threat.
+;; In XEmacs < 21.5, autosaved remote files have permission 0666 minus
+;; umask. This is a security threat.
 
 (defun tramp-set-auto-save-file-modes ()
   "Set permissions of autosaved remote files to the original permissions."
   (let ((bfn (buffer-file-name)))
-    (when (and (stringp bfn)
-	       (tramp-tramp-file-p bfn)
+    (when (and (tramp-tramp-file-p bfn)
 	       (buffer-modified-p)
 	       (stringp buffer-auto-save-file-name)
 	       (not (equal bfn buffer-auto-save-file-name)))
@@ -8312,10 +8685,9 @@
       (set-file-modes buffer-auto-save-file-name
 		      (or (file-modes bfn) (tramp-octal-to-decimal "0600"))))))
 
-(unless (or (> emacs-major-version 21)
-	    (and (featurep 'xemacs)
-		 (= emacs-major-version 21)
-		 (> emacs-minor-version 4)))
+(unless (and (featurep 'xemacs)
+	     (= emacs-major-version 21)
+	     (> emacs-minor-version 4))
   (add-hook 'auto-save-hook 'tramp-set-auto-save-file-modes)
   (add-hook 'tramp-unload-hook
 	    (lambda ()
@@ -8357,16 +8729,17 @@
 	   (and (boundp 'auth-sources)
 		(tramp-get-connection-property v "first-password-request" nil)
 		;; Try with Tramp's current method.
-		(funcall (symbol-function 'auth-source-user-or-password)
-			 "password" tramp-current-host tramp-current-method))
+		(tramp-compat-funcall
+		 'auth-source-user-or-password
+		 "password" tramp-current-host tramp-current-method))
 	   ;; Try the password cache.
 	   (when (functionp 'password-read)
 	     (unless (tramp-get-connection-property
 		      v "first-password-request" nil)
-	       (funcall (symbol-function 'password-cache-remove) key))
+	       (tramp-compat-funcall 'password-cache-remove key))
 	     (let ((password
-		    (funcall (symbol-function 'password-read) pw-prompt key)))
-	       (funcall (symbol-function 'password-cache-add) key password)
+		    (tramp-compat-funcall 'password-read pw-prompt key)))
+	       (tramp-compat-funcall 'password-cache-add key password)
 	       password))
 	   ;; Else, get the password interactively.
 	   (read-passwd pw-prompt))
@@ -8374,14 +8747,13 @@
 
 (defun tramp-clear-passwd (vec)
   "Clear password cache for connection related to VEC."
-  (when (functionp 'password-cache-remove)
-    (funcall
-     (symbol-function 'password-cache-remove)
-     (tramp-make-tramp-file-name
-      (tramp-file-name-method vec)
-      (tramp-file-name-user vec)
-      (tramp-file-name-host vec)
-      ""))))
+  (tramp-compat-funcall
+   'password-cache-remove
+   (tramp-make-tramp-file-name
+    (tramp-file-name-method vec)
+    (tramp-file-name-user vec)
+    (tramp-file-name-host vec)
+    "")))
 
 ;; Snarfed code from time-date.el and parse-time.el
 
@@ -8418,16 +8790,17 @@
   ;; Pacify byte-compiler with `symbol-function'.
   (cond ((and (fboundp 'subtract-time)
 	      (fboundp 'float-time))
-         (funcall (symbol-function 'float-time)
-		  (funcall (symbol-function 'subtract-time) t1 t2)))
+         (tramp-compat-funcall
+	  'float-time (tramp-compat-funcall 'subtract-time t1 t2)))
 	((and (fboundp 'subtract-time)
 	      (fboundp 'time-to-seconds))
-         (funcall (symbol-function 'time-to-seconds)
-		  (funcall (symbol-function 'subtract-time) t1 t2)))
+         (tramp-compat-funcall
+	  'time-to-seconds (tramp-compat-funcall 'subtract-time t1 t2)))
         ((fboundp 'itimer-time-difference)
-	 (funcall (symbol-function 'itimer-time-difference)
-		  (if (< (length t1) 3) (append t1 '(0)) t1)
-		  (if (< (length t2) 3) (append t2 '(0)) t2)))
+	 (tramp-compat-funcall
+	  'itimer-time-difference
+	  (if (< (length t1) 3) (append t1 '(0)) t1)
+	  (if (< (length t2) 3) (append t2 '(0)) t2)))
         (t
 	 (let ((time (tramp-time-subtract t1 t2)))
 	   (+ (* (car time) 65536.0)
@@ -8438,18 +8811,18 @@
   "Return a coding system like CODING-SYSTEM but with given EOL-TYPE.
 EOL-TYPE can be one of `dos', `unix', or `mac'."
   (cond ((fboundp 'coding-system-change-eol-conversion)
-         (funcall (symbol-function 'coding-system-change-eol-conversion)
-		  coding-system eol-type))
+         (tramp-compat-funcall
+	  'coding-system-change-eol-conversion coding-system eol-type))
         ((fboundp 'subsidiary-coding-system)
-         (funcall (symbol-function 'subsidiary-coding-system)
-		  coding-system
-		  (cond ((eq eol-type 'dos) 'crlf)
-			((eq eol-type 'unix) 'lf)
-			((eq eol-type 'mac) 'cr)
-			(t
-			 (error "Unknown EOL-TYPE `%s', must be %s"
-				eol-type
-				"`dos', `unix', or `mac'")))))
+         (tramp-compat-funcall
+	  'subsidiary-coding-system coding-system
+	  (cond ((eq eol-type 'dos) 'crlf)
+		((eq eol-type 'unix) 'lf)
+		((eq eol-type 'mac) 'cr)
+		(t
+		 (error "Unknown EOL-TYPE `%s', must be %s"
+			eol-type
+			"`dos', `unix', or `mac'")))))
         (t (error "Can't change EOL conversion -- is MULE missing?"))))
 
 (defun tramp-set-process-query-on-exit-flag (process flag)
@@ -8457,8 +8830,8 @@
 If the second argument flag is non-nil, Emacs will query the user before
 exiting if process is running."
   (if (fboundp 'set-process-query-on-exit-flag)
-      (funcall (symbol-function 'set-process-query-on-exit-flag) process flag)
-    (funcall (symbol-function 'process-kill-without-query) process flag)))
+      (tramp-compat-funcall 'set-process-query-on-exit-flag process flag)
+    (tramp-compat-funcall 'process-kill-without-query process flag)))
 
 
 ;; ------------------------------------------------------------
@@ -8518,8 +8891,7 @@
   ;; When Tramp is not loaded yet, its autoloads are still active.
   (tramp-unload-file-name-handlers)
   ;; ange-ftp settings must be enabled.
-  (when (functionp 'tramp-ftp-enable-ange-ftp)
-    (funcall (symbol-function 'tramp-ftp-enable-ange-ftp)))
+  (tramp-compat-funcall 'tramp-ftp-enable-ange-ftp)
   ;; Maybe its not loaded yet.
   (condition-case nil
       (unload-feature 'tramp 'force)
@@ -8546,12 +8918,10 @@
 ;;   by the files in that directory.  Add this here.
 ;; * Avoid screen blanking when hitting `g' in dired.  (Eli Tziperman)
 ;; * Make ffap.el grok Tramp filenames.  (Eli Tziperman)
-;; * Case-insensitive filename completion.  (Norbert Goevert.)
 ;; * Don't use globbing for directories with many files, as this is
 ;;   likely to produce long command lines, and some shells choke on
 ;;   long command lines.
 ;; * How to deal with MULE in `insert-file-contents' and `write-region'?
-;; * Test remote ksh or bash for tilde expansion in `tramp-find-shell'?
 ;; * abbreviate-file-name
 ;; * Better error checking.  At least whenever we see something
 ;;   strange when doing zerop, we should kill the process and start
@@ -8559,7 +8929,6 @@
 ;; * Remove unneeded parameters from methods.
 ;; * Make it work for different encodings, and for different file name
 ;;   encodings, too.  (Daniel Pittman)
-;; * Progress reports while copying files.  (Michael Kifer)
 ;; * Don't search for perl5 and perl.  Instead, only search for perl and
 ;;   then look if it's the right version (with `perl -v').
 ;; * When editing a remote CVS controlled file as a different user, VC
@@ -8616,20 +8985,23 @@
 ;;   rsync).
 ;; * Keep a second connection open for out-of-band methods like scp or
 ;;   rsync.
-;; * Support ptys in `tramp-handle-start-file-process'.  (Bug#4604)
 ;; * IMHO, it's a drawback that currently Tramp doesn't support
 ;;   Unicode in Dired file names by default.  Is it possible to
 ;;   improve Tramp to set LC_ALL to "C" only for commands where Tramp
 ;;   expects English?  Or just to set LC_MESSAGES to "C" if Tramp
 ;;   expects only English messages?  (Juri Linkov)
 ;; * Make shadowfile.el grok Tramp filenames.  (Bug#4526, Bug#4846)
-;; * Do not handle files with drive letter as remote.  (Bug#5447)
-;; * Load Tramp subpackages only when needed.  (Bug#1529, Bug#5448)
+;; * Load Tramp subpackages only when needed.  (Bug#1529, Bug#5448, Bug#5705)
 ;; * Try telnet+curl as new method.  It might be useful for busybox,
 ;;   without built-in uuencode/uudecode.
-;; * Let `shell-dynamic-complete-*' and `comint-dynamic-complete' work
-;;   on remote hosts.
-;; * Use secrets.el for password handling.
+;; * Load ~/.emacs_SHELLNAME on the remote host for `shell'.
+;; * I was wondering it it would be possible to use tramp even if I'm
+;;   actually using sshfs.  But when I launch a command I would like
+;;   to get it executed on the remote machine where the files really
+;;   are.  (Andrea Crotti)
+;; * Run emerge on two remote files.  Bug is described here:
+;;   <http://www.mail-archive.com/tramp-devel@nongnu.org/msg01041.html>.
+;;   (Bug#6850)
 
 ;; Functions for file-name-handler-alist:
 ;; diff-latest-backup-file -- in diff.el
--- a/lisp/net/trampver.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/net/trampver.el	Fri Aug 27 23:06:02 2010 +0900
@@ -1,8 +1,8 @@
 ;;; trampver.el --- Transparent Remote Access, Multiple Protocol
 ;;; lisp/trampver.el.  Generated from trampver.el.in by configure.
 
-;; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008,
-;;   2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009,
+;;   2010 Free Software Foundation, Inc.
 
 ;; Author: Kai Großjohann <kai.grossjohann@gmx.net>
 ;; Keywords: comm, processes
@@ -24,19 +24,20 @@
 
 ;;; Code:
 
-;; In the Tramp CVS repository, the version numer and the bug report address
-;; are auto-frobbed from configure.ac, so you should edit that file and run
-;; "autoconf && ./configure" to change them.  (X)Emacs version check is defined
-;; in macro AC_EMACS_INFO of aclocal.m4; should be changed only there.
+;; In the Tramp CVS repository, the version number and the bug report
+;; address are auto-frobbed from configure.ac, so you should edit that
+;; file and run "autoconf && ./configure" to change them.  (X)Emacs
+;; version check is defined in macro AC_EMACS_INFO of aclocal.m4;
+;; should be changed only there.
 
-(defconst tramp-version "2.1.18-23.2"
+(defconst tramp-version "2.1.19"
   "This version of Tramp.")
 
 (defconst tramp-bug-report-address "tramp-devel@gnu.org"
   "Email address to send bug reports to.")
 
 ;; Check for (X)Emacs version.
-(let ((x (if (or (< emacs-major-version 21)	(and (featurep 'xemacs)	     (= emacs-major-version 21)	     (< emacs-minor-version 4)))    (format "Tramp 2.1.18-pre is not fit for %s"	    (when (string-match "^.*$" (emacs-version))	      (match-string 0 (emacs-version))))    "ok")))
+(let ((x (if (or (>= emacs-major-version 22)	(and (featurep 'xemacs)	     (= emacs-major-version 21)	     (>= emacs-minor-version 4)))    "ok"    (format "Tramp 2.1.19 is not fit for %s"	    (when (string-match "^.*$" (emacs-version))	      (match-string 0 (emacs-version)))))))
   (unless (string-match "\\`ok\\'" x) (error "%s" x)))
 
 (provide 'trampver)
--- a/lisp/play/cookie1.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/play/cookie1.el	Fri Aug 27 23:06:02 2010 +0900
@@ -138,7 +138,7 @@
 				(vec (cookie-snarf phrase-file
 						   startmsg endmsg))
 				(i (length vec)))
-			   (while (> (setq i (1- i)) 0)
+			   (while (>= (setq i (1- i)) 0)
 			     (setq alist (cons (list (aref vec i)) alist)))
 			   (put sym 'completion-alist alist))))
 		   nil require-match nil nil))
--- a/lisp/progmodes/flymake.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/progmodes/flymake.el	Fri Aug 27 23:06:02 2010 +0900
@@ -1152,7 +1152,8 @@
 	  (when dir
 	    (let ((default-directory dir))
 	      (flymake-log 3 "starting process on dir %s" default-directory)))
-	  (setq process (apply 'start-process "flymake-proc" (current-buffer) cmd args))
+	  (setq process (apply 'start-file-process
+			       "flymake-proc" (current-buffer) cmd args))
 	  (set-process-sentinel process 'flymake-process-sentinel)
 	  (set-process-filter process 'flymake-process-filter)
           (push process flymake-processes)
--- a/lisp/progmodes/make-mode.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/progmodes/make-mode.el	Fri Aug 27 23:06:02 2010 +0900
@@ -1324,7 +1324,9 @@
 	(save-restriction
 	  (narrow-to-region beginning end)
 	  (makefile-backslash-region (point-min) (point-max) t)
-	  (let ((fill-paragraph-function nil))
+	  (let ((fill-paragraph-function nil)
+                ;; Adjust fill-column to allow space for the backslash.
+                (fill-column (- fill-column 1)))
 	    (fill-paragraph nil))
 	  (makefile-backslash-region (point-min) (point-max) nil)
 	  (goto-char (point-max))
@@ -1338,7 +1340,9 @@
       ;; resulting region.
       (save-restriction
 	(narrow-to-region (point) (line-beginning-position 2))
-	(let ((fill-paragraph-function nil))
+	(let ((fill-paragraph-function nil)
+              ;; Adjust fill-column to allow space for the backslash.
+              (fill-column (- fill-column 1)))
 	  (fill-paragraph nil))
 	(makefile-backslash-region (point-min) (point-max) nil))
       ;; Return non-nil to indicate it's been filled.
--- a/lisp/progmodes/python.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/progmodes/python.el	Fri Aug 27 23:06:02 2010 +0900
@@ -755,7 +755,7 @@
   '(("else" "if" "elif" "while" "for" "try" "except")
     ("elif" "if" "elif")
     ("except" "try" "except")
-    ("finally" "try" "except"))
+    ("finally" "else" "try" "except"))
   "Alist of keyword matches.
 The car of an element is a keyword introducing a statement which
 can close a block opened by a keyword in the cdr.")
--- a/lisp/progmodes/which-func.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/progmodes/which-func.el	Fri Aug 27 23:06:02 2010 +0900
@@ -145,7 +145,9 @@
 		 local-map ,which-func-keymap
 		 face which-func
 		 ;;mouse-face highlight	; currently not evaluated :-(
-		 help-echo "mouse-1: go to beginning, mouse-2: toggle rest visibility, mouse-3: go to end")
+		 help-echo "mouse-1: go to beginning\n\
+mouse-2: toggle rest visibility\n\
+mouse-3: go to end")
     "]")
   "Format for displaying the function in the mode line."
   :group 'which-func
--- a/lisp/replace.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/replace.el	Fri Aug 27 23:06:02 2010 +0900
@@ -1893,7 +1893,9 @@
       (let ((isearch-string string)
 	    (isearch-regexp regexp)
 	    (search-whitespace-regexp nil)
-	    (isearch-case-fold-search case-fold))
+	    (isearch-case-fold-search case-fold)
+	    (isearch-forward t)
+	    (isearch-error nil))
 	(isearch-lazy-highlight-new-loop range-beg range-end))))
 
 (defun replace-dehighlight ()
--- a/lisp/server.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/server.el	Fri Aug 27 23:06:02 2010 +0900
@@ -560,9 +560,9 @@
 		       :coding 'raw-text-unix
 		       ;; The other args depend on the kind of socket used.
 		       (if server-use-tcp
-			   (list :family nil
+			   (list :family 'ipv4  ;; We're not ready for IPv6 yet
 				 :service t
-				 :host (or server-host 'local)
+				 :host (or server-host "127.0.0.1") ;; See bug#6781
 				 :plist '(:authenticated nil))
 			 (list :family 'local
 			       :service server-file
--- a/lisp/simple.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/simple.el	Fri Aug 27 23:06:02 2010 +0900
@@ -784,15 +784,16 @@
        (constrain-to-field nil orig-pos t)))))
 
 (defun beginning-of-buffer (&optional arg)
-  "Move point to the beginning of the buffer; leave mark at previous position.
-With \\[universal-argument] prefix, do not set mark at previous position.
+  "Move point to the beginning of the buffer.
 With numeric arg N, put point N/10 of the way from the beginning.
-
-If the buffer is narrowed, this command uses the beginning and size
-of the accessible part of the buffer.
+If the buffer is narrowed, this command uses the beginning of the
+accessible part of the buffer.
+
+If Transient Mark mode is disabled, leave mark at previous
+position, unless a \\[universal-argument] prefix is supplied.
 
 Don't use this command in Lisp programs!
-\(goto-char (point-min)) is faster and avoids clobbering the mark."
+\(goto-char (point-min)) is faster."
   (interactive "^P")
   (or (consp arg)
       (region-active-p)
@@ -809,15 +810,16 @@
   (if (and arg (not (consp arg))) (forward-line 1)))
 
 (defun end-of-buffer (&optional arg)
-  "Move point to the end of the buffer; leave mark at previous position.
-With \\[universal-argument] prefix, do not set mark at previous position.
+  "Move point to the end of the buffer.
 With numeric arg N, put point N/10 of the way from the end.
-
-If the buffer is narrowed, this command uses the beginning and size
-of the accessible part of the buffer.
+If the buffer is narrowed, this command uses the end of the
+accessible part of the buffer.
+
+If Transient Mark mode is disabled, leave mark at previous
+position, unless a \\[universal-argument] prefix is supplied.
 
 Don't use this command in Lisp programs!
-\(goto-char (point-max)) is faster and avoids clobbering the mark."
+\(goto-char (point-max)) is faster."
   (interactive "^P")
   (or (consp arg) (region-active-p) (push-mark))
   (let ((size (- (point-max) (point-min))))
@@ -2959,7 +2961,8 @@
 the text, but put the text in the kill ring anyway.  This means that
 you can use the killing commands to copy text from a read-only buffer.
 
-This is the primitive for programs to kill text (as opposed to deleting it).
+Lisp programs should use this function for killing text.
+ (To delete text, use `delete-region'.)
 Supply two arguments, character positions indicating the stretch of text
  to be killed.
 Any command that calls this function is a \"kill command\".
@@ -3819,7 +3822,8 @@
     (setq mark-ring (cdr mark-ring)))
   (deactivate-mark))
 
-(defalias 'exchange-dot-and-mark 'exchange-point-and-mark)
+(define-obsolete-function-alias
+  'exchange-dot-and-mark 'exchange-point-and-mark "23.3")
 (defun exchange-point-and-mark (&optional arg)
   "Put the mark where point is now, and point where the mark is now.
 This command works even when the mark is not active,
--- a/lisp/subr.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/subr.el	Fri Aug 27 23:06:02 2010 +0900
@@ -219,6 +219,7 @@
 (defmacro ignore-errors (&rest body)
   "Execute BODY; if an error occurs, return nil.
 Otherwise, return result of last form in BODY."
+  (declare (debug t) (indent 0))
   `(condition-case nil (progn ,@body) (error nil)))
 
 ;;;; Basic Lisp functions.
@@ -1817,6 +1818,7 @@
 some sort of escape sequence, the ambiguity is resolved via `read-key-delay'."
   (let ((overriding-terminal-local-map read-key-empty-map)
 	(overriding-local-map nil)
+        (echo-keystrokes 0)
 	(old-global-map (current-global-map))
         (timer (run-with-idle-timer
                 ;; Wait long enough that Emacs has the time to receive and
@@ -1841,7 +1843,12 @@
                       (throw 'read-key keys)))))))
     (unwind-protect
         (progn
-	  (use-global-map read-key-empty-map)
+	  (use-global-map
+           (let ((map (make-sparse-keymap)))
+             ;; Don't hide the menu-bar and tool-bar entries.
+             (define-key map [menu-bar] (lookup-key global-map [menu-bar]))
+             (define-key map [tool-bar] (lookup-key global-map [tool-bar]))
+             map))
 	  (aref	(catch 'read-key (read-key-sequence-vector prompt nil t)) 0))
       (cancel-timer timer)
       (use-global-map old-global-map))))
--- a/lisp/term.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/term.el	Fri Aug 27 23:06:02 2010 +0900
@@ -502,8 +502,8 @@
 (defvar term-delimiter-argument-list ()
   "List of characters to recognize as separate arguments in input.
 Strings comprising a character in this list will separate the arguments
-surrounding them, and also be regarded as arguments in their own right (unlike
-whitespace).  See `term-arguments'.
+surrounding them, and also be regarded as arguments in their own right
+\(unlike whitespace).  See `term-arguments'.
 Defaults to the empty list.
 
 For shells, a good value is (?\\| ?& ?< ?> ?\\( ?\\) ?\\;).
@@ -1516,7 +1516,7 @@
 ;; term-replace-by-expanded-history-before-point Workhorse function.
 
 (defun term-read-input-ring (&optional silent)
-  "Sets the buffer's `term-input-ring' from a history file.
+  "Set the buffer's `term-input-ring' from a history file.
 The name of the file is given by the variable `term-input-ring-file-name'.
 The history ring is of size `term-input-ring-size', regardless of file size.
 If `term-input-ring-file-name' is nil this function does nothing.
@@ -1564,7 +1564,7 @@
 		 term-input-ring-index nil)))))
 
 (defun term-write-input-ring ()
-  "Writes the buffer's `term-input-ring' to a history file.
+  "Write the buffer's `term-input-ring' to a history file.
 The name of the file is given by the variable `term-input-ring-file-name'.
 The original contents of the file are lost if `term-input-ring' is not empty.
 If `term-input-ring-file-name' is nil this function does nothing.
@@ -1996,12 +1996,12 @@
   "Send input to process.
 After the process output mark, sends all text from the process mark to
 point as input to the process.  Before the process output mark, calls value
-of variable term-get-old-input to retrieve old input, copies it to the
+of variable `term-get-old-input' to retrieve old input, copies it to the
 process mark, and sends it.  A terminal newline is also inserted into the
 buffer and sent to the process.  The list of function names contained in the
 value of `term-input-filter-functions' is called on the input before sending
 it.  The input is entered into the input history ring, if the value of variable
-term-input-filter returns non-nil when called on the input.
+`term-input-filter' returns non-nil when called on the input.
 
 Any history reference may be expanded depending on the value of the variable
 `term-input-autoexpand'.  The list of function names contained in the value
@@ -2137,7 +2137,7 @@
   (term-send-string proc "\n"))
 
 (defun term-bol (arg)
-  "Goes to the beginning of line, then skips past the prompt, if any.
+  "Go to the beginning of line, then skip past the prompt, if any.
 If a prefix argument is given (\\[universal-argument]), then no prompt skip
 -- go straight to column 0.
 
@@ -3760,7 +3760,7 @@
       (goto-char saved-point))))
 
 (defun term-erase-in-display (kind)
-  "Erases (that is blanks out) part of the window.
+  "Erase (that is blank out) part of the window.
 If KIND is 0, erase from (point) to (point-max);
 if KIND is 1, erase from home to point; else erase from home to point-max."
   (term-handle-deferred-scroll)
@@ -4166,7 +4166,7 @@
 
 ;; I need a make-term that doesn't surround with *s -mm
 (defun term-ansi-make-term (name program &optional startfile &rest switches)
-"Make a term process NAME in a buffer, running PROGRAM.
+  "Make a term process NAME in a buffer, running PROGRAM.
 The name of the buffer is NAME.
 If there is already a running process in that buffer, it is not restarted.
 Optional third arg STARTFILE is the name of a file to send the contents of to
@@ -4267,7 +4267,7 @@
 for special serial ports that cannot be configured.")
 
 (defun serial-supported-or-barf ()
-  "Signal an error if serial processes are not supported"
+  "Signal an error if serial processes are not supported."
   (unless (fboundp 'make-serial-process)
     (error "Serial processes are not supported on this system")))
 
--- a/lisp/whitespace.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/whitespace.el	Fri Aug 27 23:06:02 2010 +0900
@@ -6,7 +6,7 @@
 ;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
 ;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
 ;; Keywords: data, wp
-;; Version: 12.1
+;; Version: 13.0
 ;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre
 
 ;; This file is part of GNU Emacs.
@@ -813,7 +813,7 @@
   :group 'whitespace)
 
 
-(defcustom whitespace-empty-at-bob-regexp "\\`\\(\\([ \t]*\n\\)+\\)"
+(defcustom whitespace-empty-at-bob-regexp "^\\(\\([ \t]*\n\\)+\\)"
   "Specify regexp for empty lines at beginning of buffer.
 
 If you're using `mule' package, there may be other characters besides:
@@ -828,7 +828,7 @@
   :group 'whitespace)
 
 
-(defcustom whitespace-empty-at-eob-regexp "^\\([ \t\n]+\\)\\'"
+(defcustom whitespace-empty-at-eob-regexp "^\\([ \t\n]+\\)"
   "Specify regexp for empty lines at end of buffer.
 
 If you're using `mule' package, there may be other characters besides:
@@ -1229,6 +1229,19 @@
   "Used to save locally the font-lock refontify state.
 Used by `whitespace-post-command-hook' function (which see).")
 
+(defvar whitespace-bob-marker nil
+  "Used to save locally the bob marker value.
+Used by `whitespace-post-command-hook' function (which see).")
+
+(defvar whitespace-eob-marker nil
+  "Used to save locally the eob marker value.
+Used by `whitespace-post-command-hook' function (which see).")
+
+(defvar whitespace-buffer-changed nil
+  "Used to indicate locally if buffer changed.
+Used by `whitespace-post-command-hook' and `whitespace-buffer-changed'
+functions (which see).")
+
 
 ;;;###autoload
 (defun whitespace-toggle-options (arg)
@@ -1464,10 +1477,10 @@
 	  (let (overwrite-mode)		; enforce no overwrite
 	    (goto-char (point-min))
 	    (when (re-search-forward
-		   whitespace-empty-at-bob-regexp nil t)
+		   (concat "\\`" whitespace-empty-at-bob-regexp) nil t)
 	      (delete-region (match-beginning 1) (match-end 1)))
 	    (when (re-search-forward
-		   whitespace-empty-at-eob-regexp nil t)
+		   (concat whitespace-empty-at-eob-regexp "\\'") nil t)
 	      (delete-region (match-beginning 1) (match-end 1)))))))
     ;; PROBLEM 3: 8 or more SPACEs at bol
     ;; PROBLEM 4: SPACEs before TAB
@@ -2147,8 +2160,15 @@
     (set (make-local-variable 'whitespace-point)
 	 (point))
     (set (make-local-variable 'whitespace-font-lock-refontify)
+	 0)
+    (set (make-local-variable 'whitespace-bob-marker)
+	 (point-min-marker))
+    (set (make-local-variable 'whitespace-eob-marker)
+	 (point-max-marker))
+    (set (make-local-variable 'whitespace-buffer-changed)
 	 nil)
     (add-hook 'post-command-hook #'whitespace-post-command-hook nil t)
+    (add-hook 'before-change-functions #'whitespace-buffer-changed nil t)
     ;; turn off font lock
     (set (make-local-variable 'whitespace-font-lock-mode)
 	 font-lock-mode)
@@ -2159,7 +2179,7 @@
        nil
        (list
 	;; Show SPACEs
-	(list #'whitespace-space-regexp  1 whitespace-space  t)
+	(list whitespace-space-regexp  1 whitespace-space  t)
 	;; Show HARD SPACEs
 	(list whitespace-hspace-regexp 1 whitespace-hspace t))
        t))
@@ -2168,7 +2188,7 @@
        nil
        (list
 	;; Show TABs
-	(list #'whitespace-tab-regexp 1 whitespace-tab t))
+	(list whitespace-tab-regexp 1 whitespace-tab t))
        t))
     (when (memq 'trailing whitespace-active-style)
       (font-lock-add-keywords
@@ -2297,7 +2317,8 @@
   ;; turn off font lock
   (when (whitespace-style-face-p)
     (font-lock-mode 0)
-    (remove-hook 'post-command-hook #'whitespace-post-command-hook)
+    (remove-hook 'post-command-hook #'whitespace-post-command-hook t)
+    (remove-hook 'before-change-functions #'whitespace-buffer-changed t)
     (when whitespace-font-lock
       (setq whitespace-font-lock nil
 	    font-lock-keywords   whitespace-font-lock-keywords))
@@ -2318,37 +2339,128 @@
 (defun whitespace-empty-at-bob-regexp (limit)
   "Match spaces at beginning of buffer which do not contain the point at \
 beginning of buffer."
-  (and (/= whitespace-point 1)
-       (re-search-forward whitespace-empty-at-bob-regexp limit t)))
+  (let ((b (point))
+	r)
+    (cond
+     ;; at bob
+     ((= b 1)
+      (setq r (and (/= whitespace-point 1)
+		   (looking-at whitespace-empty-at-bob-regexp)))
+      (if r
+	  (set-marker whitespace-bob-marker (match-end 1))
+	(set-marker whitespace-bob-marker b)))
+     ;; inside bob empty region
+     ((<= limit whitespace-bob-marker)
+      (setq r (looking-at whitespace-empty-at-bob-regexp))
+      (if r
+	  (when (< (match-end 1) limit)
+	    (set-marker whitespace-bob-marker (match-end 1)))
+	(set-marker whitespace-bob-marker b)))
+     ;; intersection with end of bob empty region
+     ((<= b whitespace-bob-marker)
+      (setq r (looking-at whitespace-empty-at-bob-regexp))
+      (if r
+	  (set-marker whitespace-bob-marker (match-end 1))
+	(set-marker whitespace-bob-marker b)))
+     ;; it is not inside bob empty region
+     (t
+      (setq r nil)))
+    ;; move to end of matching
+    (and r (goto-char (match-end 1)))
+    r))
+
+
+(defsubst whitespace-looking-back (regexp limit)
+  (save-excursion
+    (when (/= 0 (skip-chars-backward " \t\n" limit))
+      (unless (bolp)
+	(forward-line 1))
+      (looking-at regexp))))
 
 
 (defun whitespace-empty-at-eob-regexp (limit)
   "Match spaces at end of buffer which do not contain the point at end of \
 buffer."
-  (and (/= whitespace-point (1+ (buffer-size)))
-       (re-search-forward whitespace-empty-at-eob-regexp limit t)))
-
-
-(defun whitespace-space-regexp (limit)
-  "Match spaces."
-  (setq whitespace-font-lock-refontify t)
-  (re-search-forward whitespace-space-regexp limit t))
-
-
-(defun whitespace-tab-regexp (limit)
-  "Match tabs."
-  (setq whitespace-font-lock-refontify t)
-  (re-search-forward whitespace-tab-regexp limit t))
+  (let ((b (point))
+	(e (1+ (buffer-size)))
+	r)
+    (cond
+     ;; at eob
+     ((= limit e)
+      (when (/= whitespace-point e)
+	(goto-char limit)
+	(setq r (whitespace-looking-back whitespace-empty-at-eob-regexp b)))
+      (if r
+	  (set-marker whitespace-eob-marker (match-beginning 1))
+	(set-marker whitespace-eob-marker limit)
+	(goto-char b)))			; return back to initial position
+     ;; inside eob empty region
+     ((>= b whitespace-eob-marker)
+      (goto-char limit)
+      (setq r (whitespace-looking-back whitespace-empty-at-eob-regexp b))
+      (if r
+	  (when (> (match-beginning 1) b)
+	    (set-marker whitespace-eob-marker (match-beginning 1)))
+	(set-marker whitespace-eob-marker limit)
+	(goto-char b)))			; return back to initial position
+     ;; intersection with beginning of eob empty region
+     ((>= limit whitespace-eob-marker)
+      (goto-char limit)
+      (setq r (whitespace-looking-back whitespace-empty-at-eob-regexp b))
+      (if r
+	  (set-marker whitespace-eob-marker (match-beginning 1))
+	(set-marker whitespace-eob-marker limit)
+	(goto-char b)))			; return back to initial position
+     ;; it is not inside eob empty region
+     (t
+      (setq r nil)))
+    r))
+
+
+(defun whitespace-buffer-changed (beg end)
+  "Set `whitespace-buffer-changed' variable to t."
+  (setq whitespace-buffer-changed t))
 
 
 (defun whitespace-post-command-hook ()
   "Save current point into `whitespace-point' variable.
 Also refontify when necessary."
-  (setq whitespace-point (point))
-  (let ((refontify (or (eolp)			 ; end of line
-		       (= whitespace-point 1)))) ; beginning of buffer
-    (when (or whitespace-font-lock-refontify refontify)
-      (setq whitespace-font-lock-refontify refontify)
+  (setq whitespace-point (point))	; current point position
+  (let ((refontify
+	 (or
+	  ;; it is at end of line ...
+	  (and (eolp)
+	       ;; ... with trailing SPACE or TAB
+	       (or (= (preceding-char) ?\ )
+		   (= (preceding-char) ?\t)))
+	  ;; it is at beginning of buffer (bob)
+	  (= whitespace-point 1)
+	  ;; the buffer was modified and ...
+	  (and whitespace-buffer-changed
+	       (or
+		;; ... or inside bob whitespace region
+		(<= whitespace-point whitespace-bob-marker)
+		;; ... or at bob whitespace region border
+		(and (= whitespace-point (1+ whitespace-bob-marker))
+		     (= (preceding-char) ?\n))))
+	  ;; it is at end of buffer (eob)
+	  (= whitespace-point (1+ (buffer-size)))
+	  ;; the buffer was modified and ...
+	  (and whitespace-buffer-changed
+	       (or
+		;; ... or inside eob whitespace region
+	        (>= whitespace-point whitespace-eob-marker)
+		;; ... or at eob whitespace region border
+		(and (= whitespace-point (1- whitespace-eob-marker))
+		     (= (following-char) ?\n)))))))
+    (when (or refontify (> whitespace-font-lock-refontify 0))
+      (setq whitespace-buffer-changed nil)
+      ;; adjust refontify counter
+      (setq whitespace-font-lock-refontify
+	    (if refontify
+		1
+	      (1- whitespace-font-lock-refontify)))
+      ;; refontify
       (jit-lock-refontify))))
 
 
@@ -2387,11 +2499,11 @@
       (unless whitespace-display-table-was-local
 	(setq whitespace-display-table-was-local t
 	      whitespace-display-table
+	      (copy-sequence buffer-display-table))
+	;; asure `buffer-display-table' is unique
+	;; when two or more windows are visible.
+	(setq buffer-display-table
 	      (copy-sequence buffer-display-table)))
-      ;; asure `buffer-display-table' is unique
-      ;; when two or more windows are visible.
-      (set (make-local-variable 'buffer-display-table)
-	   (copy-sequence buffer-display-table))
       (unless buffer-display-table
 	(setq buffer-display-table (make-display-table)))
       (dolist (entry whitespace-display-mappings)
--- a/lisp/woman.el	Fri Aug 27 23:05:43 2010 +0900
+++ b/lisp/woman.el	Fri Aug 27 23:06:02 2010 +0900
@@ -3384,7 +3384,10 @@
   "Translate up to marker TO.  Do this last of all transformations."
   (if translations
       (let ((matches (car translations))
-	    (alist (cdr translations)))
+	    (alist (cdr translations))
+	    ;; Translations are case-sensitive, eg ".tr ab" does not
+	    ;; affect "A" (bug#6849).
+	    (case-fold-search nil))
 	(while (re-search-forward matches to t)
 	  ;; Done like this to retain text properties and
 	  ;; support translation of special characters:
--- a/nt/ChangeLog	Fri Aug 27 23:05:43 2010 +0900
+++ b/nt/ChangeLog	Fri Aug 27 23:06:02 2010 +0900
@@ -1,3 +1,8 @@
+2010-08-02  Óscar Fuentes  <ofv@wanadoo.es>
+
+	* cmdproxy.c (main): Use _snprintf instead of wsprintf,
+	which has a 1024 char limit on Windows (bug#6647).
+
 2010-05-07  Chong Yidong  <cyd@stupidchicken.com>
 
 	* Version 23.2 released.
--- a/nt/cmdproxy.c	Fri Aug 27 23:05:43 2010 +0900
+++ b/nt/cmdproxy.c	Fri Aug 27 23:06:02 2010 +0900
@@ -35,6 +35,9 @@
 #include <stdlib.h>  /* getenv */
 #include <string.h>  /* strlen */
 
+/* We don't want to include stdio.h because we are already duplicating
+   lots of it here */
+extern int _snprintf (char *buffer, size_t count, const char *format, ...);
 
 /*******  Mock C library routines  *********************************/
 
@@ -604,6 +607,7 @@
     {
       char * p;
       int    extra_arg_space = 0;
+      int    maxlen, remlen;
       int    run_command_dot_com;
 
       progname = getenv ("COMSPEC");
@@ -635,21 +639,27 @@
 	     case path contains spaces (fortunately it can't contain
 	     quotes, since they are illegal in path names).  */
 
-	  buf = p = alloca (strlen (progname) + extra_arg_space +
-			    strlen (cmdline) + 16);
+	  remlen = maxlen =
+	    strlen (progname) + extra_arg_space + strlen (cmdline) + 16;
+	  buf = p = alloca (maxlen + 1);
 
 	  /* Quote progname in case it contains spaces.  */
-	  p += wsprintf (p, "\"%s\"", progname);
+	  p += _snprintf (p, remlen, "\"%s\"", progname);
+	  remlen = maxlen - (p - buf);
 
 	  /* Include pass_through_args verbatim; these are just switches
              so should not need quoting.  */
 	  for (argv = pass_through_args; *argv != NULL; ++argv)
-	    p += wsprintf (p, " %s", *argv);
+	    {
+	      p += _snprintf (p, remlen, " %s", *argv);
+	      remlen = maxlen - (p - buf);
+	    }
 
 	  if (run_command_dot_com)
-	    wsprintf(p, " /e:%d /c %s", envsize, cmdline);
+	    _snprintf (p, remlen, " /e:%d /c %s", envsize, cmdline);
 	  else
-	    wsprintf(p, " /c %s", cmdline);
+	    _snprintf (p, remlen, " /c %s", cmdline);
+	  remlen = maxlen - (p - buf);
 	  cmdline = buf;
 	}
       else
@@ -669,19 +679,27 @@
 	  else
 	    path[0] = '\0';
 
-	  cmdline = p = alloca (strlen (progname) + extra_arg_space +
-				strlen (path) + 13);
+	  remlen = maxlen =
+	    strlen (progname) + extra_arg_space + strlen (path) + 13;
+	  cmdline = p = alloca (maxlen + 1);
 
 	  /* Quote progname in case it contains spaces.  */
-	  p += wsprintf (p, "\"%s\" %s", progname, path);
+	  p += _snprintf (p, remlen, "\"%s\" %s", progname, path);
+	  remlen = maxlen - (p - cmdline);
 
 	  /* Include pass_through_args verbatim; these are just switches
              so should not need quoting.  */
 	  for (argv = pass_through_args; *argv != NULL; ++argv)
-	    p += wsprintf (p, " %s", *argv);
+	    {
+	      p += _snprintf (p, remlen, " %s", *argv);
+	      remlen = maxlen - (p - cmdline);
+	    }
 
 	  if (run_command_dot_com)
-	    wsprintf (p, " /e:%d", envsize);
+	    {
+	      _snprintf (p, remlen, " /e:%d", envsize);
+	      remlen = maxlen - (p - cmdline);
+	    }
 	}
     }
 
--- a/src/ChangeLog	Fri Aug 27 23:05:43 2010 +0900
+++ b/src/ChangeLog	Fri Aug 27 23:06:02 2010 +0900
@@ -1,3 +1,60 @@
+2010-08-17  Andreas Schwab  <schwab@linux-m68k.org>
+
+	* eval.c (Flet, Feval, Fapply, apply_lambda): Use SAFE_ALLOCA_LISP
+	instead of SAFE_ALLOCA.
+
+2010-08-17  Chong Yidong  <cyd@stupidchicken.com>
+
+	* eval.c (Flet, Feval, Fapply, apply_lambda): Use SAFE_ALLOCA
+	(Bug#6214).
+
+2010-08-14  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* doc.c (Fsnarf_documentation): Set skip_file only if p[1] is S.
+
+2010-08-13  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* doc.c (Fsnarf_documentation): Initialize skip_file before
+	build-files test.
+
+2010-08-09  Peter O'Gorman <pogma@thewrittenword.com>  (tiny change)
+
+	* s/hpux10-20.h (HAVE_TERMIOS, NO_TERMIO, ORDINARY_LINK): New
+	definitions.
+	(HAVE_TERMIO): Remove.
+
+2010-08-06  Kenichi Handa  <handa@m17n.org>
+
+	* charset.c: Include <stdlib.h>
+	(struct charset_sort_data): New struct.
+	(charset_compare): New function.
+	(Fsort_charsets): New funciton.
+	(syms_of_charset): Declare Fsort_charsets as a Lisp function.
+
+	* coding.c (decode_coding_iso_2022): Fix checking of dimension
+	number in CTEXT extended segment.
+
+2010-08-01  Juanma Barranquero  <lekktu@gmail.com>
+
+	* w32fns.c (syms_of_w32fns) <x-max-tooltip-size>: Fix typo in docstring.
+	* xfns.c (syms_of_xfns) <x-max-tooltip-size>: Reflow docstring.
+
+2010-07-30  Juanma Barranquero  <lekktu@gmail.com>
+
+	* fns.c (Fsubstring_no_properties, Fnthcdr, Ffeaturep)
+	(Fhash_table_size): Fix typos in docstrings.
+	(Fmake_hash_table): Doc fix.
+
+2010-07-28  Juanma Barranquero  <lekktu@gmail.com>
+
+	* minibuf.c (syms_of_minibuf) <read-buffer-function>:
+	Doc fix (bug#5625).
+
+2010-07-27  Ken Brown  <kbrown@cornell.edu>
+
+	* dired.c (DIRENTRY_NONEMPTY) [cygwin]: Use d_ino instead of
+	the MSDOS definition.
+
 2010-07-25  Christoph Scholtes  <cschol2112@gmail.com>
 
 	* minibuf.c (Fread_buffer): Doc fix (bug#6528).
--- a/src/charset.c	Fri Aug 27 23:05:43 2010 +0900
+++ b/src/charset.c	Fri Aug 27 23:06:02 2010 +0900
@@ -28,6 +28,7 @@
 #include <config.h>
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <unistd.h>
 #include <ctype.h>
 #include <sys/types.h>
@@ -2139,23 +2140,22 @@
     charset = CHAR_CHARSET (XINT (ch));
   else
     {
-      Lisp_Object charset_list;
-
       if (CONSP (restriction))
 	{
-	  for (charset_list = Qnil; CONSP (restriction);
-	       restriction = XCDR (restriction))
+	  int c = XFASTINT (ch);
+
+	  for (; CONSP (restriction); restriction = XCDR (restriction))
 	    {
-	      int id;
+	      struct charset *charset;
 
-	      CHECK_CHARSET_GET_ID (XCAR (restriction), id);
-	      charset_list = Fcons (make_number (id), charset_list);
+	      CHECK_CHARSET_GET_CHARSET (XCAR (restriction), charset);
+	      if (ENCODE_CHAR (charset, c) != CHARSET_INVALID_CODE (charset))
+		return XCAR (restriction);
 	    }
-	  charset_list = Fnreverse (charset_list);
+	  return Qnil;
 	}
-      else
-	charset_list = coding_system_charset_list (restriction);
-      charset = char_charset (XINT (ch), charset_list, NULL);
+      restriction = coding_system_charset_list (restriction);
+      charset = char_charset (XINT (ch), restriction, NULL);
       if (! charset)
 	return Qnil;
     }
@@ -2312,6 +2312,69 @@
   return make_number (id);
 }
 
+struct charset_sort_data
+{
+  Lisp_Object charset;
+  int id;
+  int priority;
+};
+
+static int
+charset_compare (const void *d1, const void *d2)
+{
+  const struct charset_sort_data *data1 = d1, *data2 = d2;
+  return (data1->priority - data2->priority);
+}
+
+DEFUN ("sort-charsets", Fsort_charsets, Ssort_charsets, 1, 1, 0,
+       doc: /* Sort charset list CHARSETS by a priority of each charset.
+Return the sorted list.  CHARSETS is modified by side effects.
+See also `charset-priority-list' and `set-charset-priority'.  */)
+     (Lisp_Object charsets)
+{
+  Lisp_Object len = Flength (charsets);
+  int n = XFASTINT (len), i, j, done;
+  Lisp_Object tail, elt, attrs;
+  struct charset_sort_data *sort_data;
+  int id, min_id, max_id;
+  USE_SAFE_ALLOCA;
+
+  if (n == 0)
+    return Qnil;
+  SAFE_ALLOCA (sort_data, struct charset_sort_data *, sizeof (*sort_data) * n);
+  for (tail = charsets, i = 0; CONSP (tail); tail = XCDR (tail), i++)
+    {
+      elt = XCAR (tail);
+      CHECK_CHARSET_GET_ATTR (elt, attrs);
+      sort_data[i].charset = elt;
+      sort_data[i].id = id = XINT (CHARSET_ATTR_ID (attrs));
+      if (i == 0)
+	min_id = max_id = id;
+      else if (id < min_id)
+	min_id = id;
+      else if (id > max_id)
+	max_id = id;
+    }
+  for (done = 0, tail = Vcharset_ordered_list, i = 0;
+       done < n && CONSP (tail); tail = XCDR (tail), i++)
+    {
+      elt = XCAR (tail);
+      id = XFASTINT (elt);
+      if (id >= min_id && id <= max_id)
+	for (j = 0; j < n; j++)
+	  if (sort_data[j].id == id)
+	    {
+	      sort_data[j].priority = i;
+	      done++;
+	    }
+    }
+  qsort (sort_data, n, sizeof *sort_data, charset_compare);
+  for (i = 0, tail = charsets; CONSP (tail); tail = XCDR (tail), i++)
+    XSETCAR (tail, sort_data[i].charset);
+  SAFE_FREE ();
+  return charsets;
+}
+
 
 void
 init_charset ()
@@ -2414,6 +2477,7 @@
   defsubr (&Scharset_priority_list);
   defsubr (&Sset_charset_priority);
   defsubr (&Scharset_id_internal);
+  defsubr (&Ssort_charsets);
 
   DEFVAR_LISP ("charset-map-path", &Vcharset_map_path,
 	       doc: /* *List of directories to search for charset map files.  */);
--- a/src/coding.c	Fri Aug 27 23:05:43 2010 +0900
+++ b/src/coding.c	Fri Aug 27 23:06:02 2010 +0900
@@ -3935,7 +3935,7 @@
 		  int size;
 
 		  ONE_MORE_BYTE (dim);
-		  if (dim < 0 || dim > 4)
+		  if (dim < '0' || dim > '4')
 		    goto invalid_code;
 		  ONE_MORE_BYTE (M);
 		  if (M < 128)
--- a/src/dired.c	Fri Aug 27 23:05:43 2010 +0900
+++ b/src/dired.c	Fri Aug 27 23:06:02 2010 +0900
@@ -72,8 +72,7 @@
 #endif /* not MSDOS */
 #endif /* not SYSV_SYSTEM_DIR */
 
-/* Some versions of Cygwin don't have d_ino in `struct dirent'.  */
-#if defined(MSDOS) || defined(__CYGWIN__)
+#ifdef MSDOS
 #define DIRENTRY_NONEMPTY(p) ((p)->d_name[0] != 0)
 #else
 #define DIRENTRY_NONEMPTY(p) ((p)->d_ino)
--- a/src/doc.c	Fri Aug 27 23:05:43 2010 +0900
+++ b/src/doc.c	Fri Aug 27 23:06:02 2010 +0900
@@ -640,24 +640,28 @@
       p = buf;
       end = buf + (filled < 512 ? filled : filled - 128);
       while (p != end && *p != '\037') p++;
-      /* p points to ^_Ffunctionname\n or ^_Vvarname\n.  */
+      /* p points to ^_Ffunctionname\n or ^_Vvarname\n or ^_Sfilename\n.  */
       if (p != end)
 	{
 	  end = (char *) index (p, '\n');
 
           /* See if this is a file name, and if it is a file in build-files.  */
-          if (p[1] == 'S' && end - p > 4 && end[-2] == '.'
-              && (end[-1] == 'o' || end[-1] == 'c'))
+          if (p[1] == 'S')
             {
-              int len = end - p - 2;
-              char *fromfile = alloca (len + 1);
-              strncpy (fromfile, &p[2], len);
-              fromfile[len] = 0;
-              if (fromfile[len-1] == 'c')
-                fromfile[len-1] = 'o';
+              skip_file = 0;
+              if (end - p > 4 && end[-2] == '.'
+                  && (end[-1] == 'o' || end[-1] == 'c'))
+                {
+                  int len = end - p - 2;
+                  char *fromfile = alloca (len + 1);
+                  strncpy (fromfile, &p[2], len);
+                  fromfile[len] = 0;
+                  if (fromfile[len-1] == 'c')
+                    fromfile[len-1] = 'o';
 
-	      skip_file = NILP (Fmember (build_string (fromfile),
-					 Vbuild_files));
+                  skip_file = NILP (Fmember (build_string (fromfile),
+                                             Vbuild_files));
+                }
             }
 
 	  sym = oblookup (Vobarray, p + 2,
--- a/src/eval.c	Fri Aug 27 23:05:43 2010 +0900
+++ b/src/eval.c	Fri Aug 27 23:06:02 2010 +0900
@@ -1028,12 +1028,13 @@
   int count = SPECPDL_INDEX ();
   register int argnum;
   struct gcpro gcpro1, gcpro2;
+  USE_SAFE_ALLOCA;
 
   varlist = Fcar (args);
 
   /* Make space to hold the values to give the bound variables */
   elt = Flength (varlist);
-  temps = (Lisp_Object *) alloca (XFASTINT (elt) * sizeof (Lisp_Object));
+  SAFE_ALLOCA_LISP (temps, XFASTINT (elt));
 
   /* Compute the values and store them in `temps' */
 
@@ -1066,6 +1067,7 @@
     }
 
   elt = Fprogn (Fcdr (args));
+  SAFE_FREE ();
   return unbind_to (count, elt);
 }
 
@@ -2299,8 +2301,9 @@
 	  /* Pass a vector of evaluated arguments */
 	  Lisp_Object *vals;
 	  register int argnum = 0;
-
-	  vals = (Lisp_Object *) alloca (XINT (numargs) * sizeof (Lisp_Object));
+	  USE_SAFE_ALLOCA;
+
+	  SAFE_ALLOCA_LISP (vals, XINT (numargs));
 
 	  GCPRO3 (args_left, fun, fun);
 	  gcpro3.var = vals;
@@ -2318,6 +2321,7 @@
 
 	  val = (*XSUBR (fun)->function) (XINT (numargs), vals);
 	  UNGCPRO;
+	  SAFE_FREE ();
 	  goto done;
 	}
 
@@ -2430,8 +2434,9 @@
   register int i, numargs;
   register Lisp_Object spread_arg;
   register Lisp_Object *funcall_args;
-  Lisp_Object fun;
+  Lisp_Object fun, retval;
   struct gcpro gcpro1;
+  USE_SAFE_ALLOCA;
 
   fun = args [0];
   funcall_args = 0;
@@ -2470,8 +2475,7 @@
 	{
 	  /* Avoid making funcall cons up a yet another new vector of arguments
 	     by explicitly supplying nil's for optional values */
-	  funcall_args = (Lisp_Object *) alloca ((1 + XSUBR (fun)->max_args)
-						 * sizeof (Lisp_Object));
+	  SAFE_ALLOCA_LISP (funcall_args, 1 + XSUBR (fun)->max_args);
 	  for (i = numargs; i < XSUBR (fun)->max_args;)
 	    funcall_args[++i] = Qnil;
 	  GCPRO1 (*funcall_args);
@@ -2483,8 +2487,7 @@
      function itself as well as its arguments.  */
   if (!funcall_args)
     {
-      funcall_args = (Lisp_Object *) alloca ((1 + numargs)
-					     * sizeof (Lisp_Object));
+      SAFE_ALLOCA_LISP (funcall_args, 1 + numargs);
       GCPRO1 (*funcall_args);
       gcpro1.nvars = 1 + numargs;
     }
@@ -2500,7 +2503,11 @@
     }
 
   /* By convention, the caller needs to gcpro Ffuncall's args.  */
-  RETURN_UNGCPRO (Ffuncall (gcpro1.nvars, funcall_args));
+  retval = Ffuncall (gcpro1.nvars, funcall_args);
+  UNGCPRO;
+  SAFE_FREE ();
+
+  return retval;
 }
 
 /* Run hook variables in various ways.  */
@@ -3108,9 +3115,10 @@
   struct gcpro gcpro1, gcpro2, gcpro3;
   register int i;
   register Lisp_Object tem;
+  USE_SAFE_ALLOCA;
 
   numargs = Flength (args);
-  arg_vector = (Lisp_Object *) alloca (XINT (numargs) * sizeof (Lisp_Object));
+  SAFE_ALLOCA_LISP (arg_vector, XINT (numargs));
   args_left = args;
 
   GCPRO3 (*arg_vector, args_left, fun);
@@ -3139,6 +3147,7 @@
     tem = call_debugger (Fcons (Qexit, Fcons (tem, Qnil)));
   /* Don't do it again when we return to eval.  */
   backtrace_list->debug_on_exit = 0;
+  SAFE_FREE ();
   return tem;
 }
 
--- a/src/fns.c	Fri Aug 27 23:05:43 2010 +0900
+++ b/src/fns.c	Fri Aug 27 23:06:02 2010 +0900
@@ -238,9 +238,8 @@
   return Qt;
 }
 
-DEFUN ("compare-strings", Fcompare_strings,
-       Scompare_strings, 6, 7, 0,
-doc: /* Compare the contents of two strings, converting to multibyte if needed.
+DEFUN ("compare-strings", Fcompare_strings, Scompare_strings, 6, 7, 0,
+       doc: /* Compare the contents of two strings, converting to multibyte if needed.
 In string STR1, skip the first START1 characters and stop at END1.
 In string STR2, skip the first START2 characters and stop at END2.
 END1 and END2 default to the full lengths of the respective strings.
@@ -1259,7 +1258,7 @@
 
 DEFUN ("substring-no-properties", Fsubstring_no_properties, Ssubstring_no_properties, 1, 3, 0,
        doc: /* Return a substring of STRING, without text properties.
-It starts at index FROM and ending before TO.
+It starts at index FROM and ends before TO.
 TO may be nil or omitted; then the substring runs to the end of STRING.
 If FROM is nil or omitted, the substring starts at the beginning of STRING.
 If FROM or TO is negative, it counts from the end.
@@ -1355,7 +1354,7 @@
 }
 
 DEFUN ("nthcdr", Fnthcdr, Snthcdr, 2, 2, 0,
-       doc: /* Take cdr N times on LIST, returns the result.  */)
+       doc: /* Take cdr N times on LIST, return the result.  */)
      (n, list)
      Lisp_Object n;
      register Lisp_Object list;
@@ -1396,7 +1395,7 @@
 }
 
 DEFUN ("member", Fmember, Smember, 2, 2, 0,
-doc: /* Return non-nil if ELT is an element of LIST.  Comparison done with `equal'.
+       doc: /* Return non-nil if ELT is an element of LIST.  Comparison done with `equal'.
 The value is actually the tail of LIST whose car is ELT.  */)
      (elt, list)
      register Lisp_Object elt;
@@ -1416,7 +1415,7 @@
 }
 
 DEFUN ("memq", Fmemq, Smemq, 2, 2, 0,
-doc: /* Return non-nil if ELT is an element of LIST.  Comparison done with `eq'.
+       doc: /* Return non-nil if ELT is an element of LIST.  Comparison done with `eq'.
 The value is actually the tail of LIST whose car is ELT.  */)
      (elt, list)
      register Lisp_Object elt, list;
@@ -1443,7 +1442,7 @@
 }
 
 DEFUN ("memql", Fmemql, Smemql, 2, 2, 0,
-doc: /* Return non-nil if ELT is an element of LIST.  Comparison done with `eql'.
+       doc: /* Return non-nil if ELT is an element of LIST.  Comparison done with `eql'.
 The value is actually the tail of LIST whose car is ELT.  */)
      (elt, list)
      register Lisp_Object elt;
@@ -2829,7 +2828,7 @@
 extern Lisp_Object Vafter_load_alist;
 
 DEFUN ("featurep", Ffeaturep, Sfeaturep, 1, 2, 0,
-       doc: /* Returns t if FEATURE is present in this Emacs.
+       doc: /* Return t if FEATURE is present in this Emacs.
 
 Use this to conditionalize execution of lisp code based on the
 presence or absence of Emacs or environment extensions.
@@ -4627,8 +4626,8 @@
 multiplying the old size with that factor.  Default is 1.5.
 
 :rehash-threshold THRESHOLD -- THRESHOLD must a float > 0, and <= 1.0.
-Resize the hash table when ratio of the number of entries in the
-table.  Default is 0.8.
+Resize the hash table when the ratio (number of entries / table size)
+is greater or equal than THRESHOLD.  Default is 0.8.
 
 :weakness WEAK -- WEAK must be one of nil, t, `key', `value',
 `key-or-value', or `key-and-value'.  If WEAK is not nil, the table
@@ -4757,7 +4756,7 @@
 DEFUN ("hash-table-size", Fhash_table_size, Shash_table_size, 1, 1, 0,
        doc: /* Return the size of TABLE.
 The size can be used as an argument to `make-hash-table' to create
-a hash table than can hold as many elements of TABLE holds
+a hash table than can hold as many elements as TABLE holds
 without need for resizing.  */)
      (table)
        Lisp_Object table;
--- a/src/minibuf.c	Fri Aug 27 23:05:43 2010 +0900
+++ b/src/minibuf.c	Fri Aug 27 23:06:02 2010 +0900
@@ -2131,7 +2131,8 @@
   staticpro (&Qread_expression_history);
 
   DEFVAR_LISP ("read-buffer-function", &Vread_buffer_function,
-	       doc: /* If this is non-nil, `read-buffer' does its work by calling this function.  */);
+	       doc: /* If this is non-nil, `read-buffer' does its work by calling this function.
+The function is called with the arguments passed to `read-buffer'.  */);
   Vread_buffer_function = Qnil;
 
   DEFVAR_BOOL ("read-buffer-completion-ignore-case",
--- a/src/s/hpux10-20.h	Fri Aug 27 23:05:43 2010 +0900
+++ b/src/s/hpux10-20.h	Fri Aug 27 23:06:02 2010 +0900
@@ -41,12 +41,10 @@
 
 #define FIRST_PTY_LETTER 'p'
 
-/*
- *	Define HAVE_TERMIO if the system provides sysV-style ioctls
- *	for terminal control.
- */
+#define HAVE_TERMIOS
+#define NO_TERMIO
 
-#define HAVE_TERMIO
+#define ORDINARY_LINK
 
 /*
  *	Define HAVE_PTYS if the system supports pty devices.
--- a/src/w32fns.c	Fri Aug 27 23:05:43 2010 +0900
+++ b/src/w32fns.c	Fri Aug 27 23:06:02 2010 +0900
@@ -7199,7 +7199,7 @@
 
   DEFVAR_LISP ("x-max-tooltip-size", &Vx_max_tooltip_size,
 	       doc: /* Maximum size for tooltips.
-Value is a pair (COLUMNS . ROWS). Text larger than this is clipped.  */);
+Value is a pair (COLUMNS . ROWS).  Text larger than this is clipped.  */);
   Vx_max_tooltip_size = Fcons (make_number (80), make_number (40));
 
   DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager,
--- a/src/xfns.c	Fri Aug 27 23:05:43 2010 +0900
+++ b/src/xfns.c	Fri Aug 27 23:06:02 2010 +0900
@@ -1025,7 +1025,7 @@
 
   if (FRAME_X_DISPLAY_INFO (f)->invisible_cursor == 0)
     FRAME_X_DISPLAY_INFO (f)->invisible_cursor = make_invisible_cursor (f);
-  
+
   if (cursor != x->text_cursor
       && x->text_cursor != 0)
     XFreeCursor (dpy, x->text_cursor);
@@ -3072,7 +3072,7 @@
       if (system_font) font_param = make_string (system_font,
                                                  strlen (system_font));
     }
-  
+
   font = !NILP (font_param) ? font_param
     : x_get_arg (dpyinfo, parms, Qfont, "font", "Font", RES_TYPE_STRING);
 
@@ -5646,7 +5646,7 @@
   font_param = Ffont_get (font, intern (":name"));
   if (STRINGP (font_param))
     default_name = xstrdup (SDATA (font_param));
-  else 
+  else
     {
       font_param = Fframe_parameter (frame, Qfont_param);
       if (STRINGP (font_param))
@@ -5657,7 +5657,7 @@
     default_name = xstrdup (x_last_font_name);
 
   /* Convert fontconfig names to Gtk names, i.e. remove - before number */
-  if (default_name) 
+  if (default_name)
     {
       char *p = strrchr (default_name, '-');
       if (p)
@@ -5918,8 +5918,8 @@
   Vx_cursor_fore_pixel = Qnil;
 
   DEFVAR_LISP ("x-max-tooltip-size", &Vx_max_tooltip_size,
-    doc: /* Maximum size for tooltips.  Value is a pair (COLUMNS . ROWS).
-Text larger than this is clipped.  */);
+    doc: /* Maximum size for tooltips.
+Value is a pair (COLUMNS . ROWS).  Text larger than this is clipped.  */);
   Vx_max_tooltip_size = Fcons (make_number (80), make_number (40));
 
   DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager,