]> code.delx.au - gnu-emacs/commitdiff
Document some changes about windows.
authorXue Fuqiao <xfq@gnu.org>
Thu, 27 Feb 2014 14:10:55 +0000 (22:10 +0800)
committerXue Fuqiao <xfq@gnu.org>
Thu, 27 Feb 2014 14:10:55 +0000 (22:10 +0800)
* doc/lispref/windows.texi (Window Sizes): Document `window-size'.
(Display Action Functions): Document `display-buffer-at-bottom'.
(Window Configurations): Minor fixes.

* doc/lispref/modes.texi (Header Lines): Document `window-header-line-height'.

* doc/lispref/display.texi (Scroll Bars): Document `window-scroll-bar-width'.

* etc/NEWS: Related markup.

18 files changed:
doc/emacs/ChangeLog
doc/emacs/basic.texi
doc/emacs/indent.texi
doc/emacs/programs.texi
doc/lispref/ChangeLog
doc/lispref/display.texi
doc/lispref/modes.texi
doc/lispref/text.texi
doc/lispref/windows.texi
doc/misc/cc-mode.texi
doc/misc/octave-mode.texi
doc/misc/vip.texi
etc/NEWS
lisp/ChangeLog
lisp/net/tramp-adb.el
lisp/net/tramp.el
test/ChangeLog
test/automated/tramp-tests.el

index 55c92de24624cb4d0ad30bcabef891f3709594be..2433e3c8b8f62b71a44ce995eac9d0a3512a52ca 100644 (file)
@@ -1,3 +1,12 @@
+2014-02-27  Xue Fuqiao  <xfq@gnu.org>
+
+       * programs.texi (Basic Indent):
+       (Other C Commands): Fix the description of RET and `C-j'.
+
+       * indent.texi (Indentation Commands): Move the description of
+       `C-j' from here...
+       * basic.texi (Inserting Text): ... to here.
+
 2014-02-25  Glenn Morris  <rgm@gnu.org>
 
        * custom.texi (Terminal Init):
index 27a8ba9438e90f509e8159e8fa07511472dcce70..f2ec11c2c1e15b7a5b77c586ae752ed398f4fb92 100644 (file)
@@ -40,14 +40,20 @@ forward, so that point remains just after the inserted text.
 @xref{Point}.
 
 @kindex RET
+@kindex C-j
 @cindex newline
+@findex electric-indent-just-newline
   To end a line and start a new one, type @key{RET} (@code{newline}).
 (The @key{RET} key may be labeled @key{Return} or @key{Enter} on your
 keyboard, but we refer to it as @key{RET} in this manual.)  This
-command inserts a newline character into the buffer.  If point is at
-the end of the line, the effect is to create a new blank line after
-it; if point is in the middle of a line, the line is split at that
-position.
+command inserts a newline character into the buffer, then indent
+(@pxref{Indentation}) accroding to major mode.  If point is at the end
+of the line, the effect is to create a new blank line after it and
+indent the new line; if point is in the middle of a line, the line is
+split at that position.  To turn off the auto-indentation, you can
+either desable Electric Indent mode (@pxref{Indent Convenience}) or
+type @kbd{C-j}, which inserts just a newline, without any
+auto-indentation.
 
   As we explain later in this manual, you can change the way Emacs
 handles text insertion by turning on @dfn{minor modes}.  For instance,
index 9aec6202de633543bd341e8cc1f147e8d943898c..78e2e925e410b94e312f11d56f91d5ee2bcaf49c 100644 (file)
@@ -64,11 +64,6 @@ Emacs provides a variety of commands to perform indentation in other
 ways.
 
 @table @kbd
-@item C-j
-@kindex C-j
-@findex newline-and-indent
-Perform @key{RET} followed by @key{TAB} (@code{newline-and-indent}).
-
 @item C-M-o
 @kindex C-M-o
 @findex split-line
index 26e9539d750b698986c05552aa1b6c55827f04e4..4a6da9e4fd64dbcd8f6138e122d2b600ba9247c2 100644 (file)
@@ -366,9 +366,9 @@ which reformats Lisp objects with nice-looking indentation.
 @table @kbd
 @item @key{TAB}
 Adjust indentation of current line (@code{indent-for-tab-command}).
-@item C-j
+@item @key{RET}
 Insert a newline, then adjust indentation of following line
-(@code{newline-and-indent}).
+(@code{newline}).
 @end table
 
 @kindex TAB @r{(programming modes)}
@@ -382,12 +382,9 @@ the current line, based on the indentation and syntactic content of
 the preceding lines; if the region is active, @key{TAB} indents each
 line within the region, not just the current line.
 
-@kindex C-j @r{(indenting source code)}
-@findex newline-and-indent
-  The command @kbd{C-j} (@code{newline-and-indent}), which was
-documented in @ref{Indentation Commands}, does the same as @key{RET}
-followed by @key{TAB}: it inserts a new line, then adjusts the line's
-indentation.
+  The command @key{RET} (@code{newline}), which was documented in
+@ref{Inserting Text}, does the same as @key{C-j} followed by
+@key{TAB}: it inserts a new line, then adjusts the line's indentation.
 
   When indenting a line that starts within a parenthetical grouping,
 Emacs usually places the start of the line under the preceding line
@@ -1681,18 +1678,18 @@ hungry-delete feature is enabled.
 @findex c-context-line-break
 This command inserts a line break and indents the new line in a manner
 appropriate to the context.  In normal code, it does the work of
-@kbd{C-j} (@code{newline-and-indent}), in a C preprocessor line it
-additionally inserts a @samp{\} at the line break, and within comments
-it's like @kbd{M-j} (@code{c-indent-new-comment-line}).
+@key{RET} (@code{newline}), in a C preprocessor line it additionally
+inserts a @samp{\} at the line break, and within comments it's like
+@kbd{M-j} (@code{c-indent-new-comment-line}).
 
 @code{c-context-line-break} isn't bound to a key by default, but it
 needs a binding to be useful.  The following code will bind it to
-@kbd{C-j}.  We use @code{c-initialization-hook} here to make sure
+@kbd{RET}.  We use @code{c-initialization-hook} here to make sure
 the keymap is loaded before we try to change it.
 
 @example
 (defun my-bind-clb ()
-  (define-key c-mode-base-map "\C-j"
+  (define-key c-mode-base-map "\C-m"
               'c-context-line-break))
 (add-hook 'c-initialization-hook 'my-bind-clb)
 @end example
@@ -1812,6 +1809,7 @@ defines these commands:
 @table @kbd
 @item @key{TAB}
 @code{tab-to-tab-stop}.
+@c FIXME: Maybe this should be consistent with other programming modes.
 @item C-j
 Insert a newline and then indent using @code{tab-to-tab-stop}.
 @item :
index 8d473033bd295b483f918b39e487d4e31b14f284..f32f88c18aebb6034d9a981d250d6023cf940ff6 100644 (file)
@@ -1,5 +1,18 @@
 2014-02-27  Xue Fuqiao  <xfq@gnu.org>
 
+       * windows.texi (Window Sizes): Document `window-size'.
+       (Display Action Functions): Document `display-buffer-at-bottom'.
+       (Window Configurations): Minor fixes.
+
+       * modes.texi (Header Lines): Document `window-header-line-height'.
+
+       * display.texi (Scroll Bars): Document `window-scroll-bar-width'.
+
+       * windows.texi (Window Sizes, Resizing Windows): Document some
+       pixelwise window operations.
+
+       * text.texi (Margins): Fix the description of RET and `C-j'.
+
        * frames.texi (Multiple Terminals): Document
        `display-monitor-attributes-list' and `display-monitor-attributes'.
        (Display Feature Testing): Add some notes about multi-monitor.
index 519d33f584415316ab7feaa338ec3666a2c8e1c5..496fbf87041d6ca0ac3dbe1a1dcfc30c96b0d4ba 100644 (file)
@@ -3849,6 +3849,12 @@ bar actually occupies.
 @var{horizontal-type} is not actually meaningful.
 @end defun
 
+@defun window-scroll-bar-width &optional window
+This function returns the width of @var{window}'s vertical scrollbar,
+in pixels.  @var{window} must be a live window.  If @var{window} is
+@code{nil} or omitted, it will be the selected window.
+@end defun
+
 If you don't specify these values for a window with
 @code{set-window-scroll-bars}, the buffer-local variables
 @code{scroll-bar-mode} and @code{scroll-bar-width} in the buffer being
index df0dd1a58e008e11a682242ac408561e9c89dffe..e12d00a5b59ab193806408e895058138db8e6ca1 100644 (file)
@@ -2221,6 +2221,15 @@ is the same as for @code{mode-line-format} (@pxref{Mode Line Data}).
 It is normally @code{nil}, so that ordinary buffers have no header line.
 @end defvar
 
+The function @code{window-header-line-height} returns the height of
+the header line:
+
+@defun window-header-line-height &optional window
+Return the height of @var{window}'s header line, in pixels.
+@var{window} must be a live window.  If @var{window} is @code{nil} or
+omitted, it will be the selected window.
+@end defun
+
   A window that is just one line tall never displays a header line.  A
 window that is two lines tall cannot display both a mode line and a
 header line at once; if it has a mode line, then it does not display a
index 18701465d0f84a7c2e9d0664628824127d559004..9df6cf61e06aec0c1efcd2dbd3140b80c95ced34 100644 (file)
@@ -1717,7 +1717,7 @@ is value of @code{indent-line-function} in Paragraph-Indent Text mode.
 
 @defopt left-margin
 This variable specifies the base left margin column.  In Fundamental
-mode, @kbd{C-j} indents to this column.  This variable automatically
+mode, @kbd{RET} indents to this column.  This variable automatically
 becomes buffer-local when set in any fashion.
 @end defopt
 
index f19a08c85e7e35c035111fb9763fdc56b0cca882..ea7856d6f7f7f3474adffdcefb0ac4f914bbe894 100644 (file)
@@ -413,6 +413,22 @@ default font.  Thus, if a window is displaying text with a different
 font or size, the reported height and width for that window may differ
 from the actual number of text lines or columns displayed within it.
 
+@defun window-size &optional window horizontal pixelwise round
+This function returns the height or width of @var{window}.
+@var{window} must be a valid window.  The default value of
+@var{window} is the selected window.
+
+If @var{horizontal} is omitted or nil, return the total height of
+@var{window}, in lines; otherwise return the total width in columns.
+
+The optional argument @var{pixelwise} means return size of
+@var{window}, in pixels.
+
+The optional argument @var{round} is ignored if @var{pixelwise} is
+non-@code{nil}.  Otherwise it is handled as for
+@code{window-total-height} and @code{window-total-width}.
+@end defun
+
 @cindex window height
 @cindex height of a window
 @cindex total height of a window
@@ -427,26 +443,55 @@ height of a frame is not the same as the height of its windows, since
 a frame may also contain an echo area, menu bar, and tool bar
 (@pxref{Size and Position}).
 
-@defun window-total-height &optional window
+@defun window-total-height &optional window round
 This function returns the total height, in lines, of the window
 @var{window}.  If @var{window} is omitted or @code{nil}, it defaults
 to the selected window.  If @var{window} is an internal window, the
 return value is the total height occupied by its descendant windows.
+
+If @var{window}'s pixel height is not an integral multiple of its
+frame's character height, the number of lines occupied by @var{window}
+is rounded internally.  This is done in a way such that, if
+@var{window} is a parent window, the sum of the total heights of all
+its children internally equals the total height of @var{window}.
+
+If the optional argument @var{round} is @code{ceiling}, this function
+will return the smallest integer larger than @var{window}'s pixel
+height divided by the character height of @var{window}'s frame; if it
+is @code{floor}, return the largest integer smaller than
+@var{window}'s pixel height divided by the character height of
+@var{window}'s frame.  Any other value of @var{round} means to return
+the internal total height of @var{window}.
 @end defun
 
-@defun window-total-width &optional window
+@defun window-total-width &optional window round
 This function returns the total width, in columns, of the window
 @var{window}.  If @var{window} is omitted or @code{nil}, it defaults
 to the selected window.  If @var{window} is internal, the return value
 is the total width occupied by its descendant windows.
+
+If @var{window}'s pixel width is not an integral multiple of its
+frame's character width, the number of lines occupied by @var{window}
+is rounded internally.  This is done in a way such that, if
+@var{window} is a parent window, the sum of the total widths of all
+its children internally equals the total width of @var{window}.
+
+If the optional argument @var{round} is @code{ceiling}, this function
+will return the smallest integer larger than @var{window}'s pixel
+width divided by the character width of @var{window}'s frame; if it is
+@code{floor}, return the largest integer smaller than @var{window}'s
+pixel width divided by the character width of @var{window}'s frame.
+Any other value of @var{round} means to return the internal total
+width of @var{window}.
 @end defun
 
-@defun window-total-size &optional window horizontal
+@defun window-total-size &optional window horizontal round
 This function returns either the total height or width of the window
 @var{window}.  If @var{horizontal} is omitted or @code{nil}, this is
 equivalent to calling @code{window-total-height} for @var{window};
 otherwise it is equivalent to calling @code{window-total-width} for
-@var{window}.
+@var{window}.  The optional argument @code{ROUND} is handled as for
+@code{window-total-height} and @code{window-total-width}.
 @end defun
 
 @cindex full-width window
@@ -479,7 +524,7 @@ which does not include the mode or header line.  Similarly, the
 @dfn{body width} is the width of the text area, which does not include
 the scroll bar, fringes, or margins.
 
-@defun window-body-height &optional window
+@defun window-body-height &optional window pixelwise
 This function returns the body height, in lines, of the window
 @var{window}.  If @var{window} is omitted or @code{nil}, it defaults
 to the selected window; otherwise it must be a live window.
@@ -489,7 +534,7 @@ that counts as a whole line; to exclude such a partially-visible line,
 use @code{window-text-height}, below.
 @end defun
 
-@defun window-body-width &optional window
+@defun window-body-width &optional window pixelwise
 This function returns the body width, in columns, of the window
 @var{window}.  If @var{window} is omitted or @code{nil}, it defaults
 to the selected window; otherwise it must be a live window.
@@ -571,7 +616,7 @@ changed except by resizing the frame (@pxref{Size and Position}).
 arguments.  Resizing an internal window causes its child windows to be
 resized to fit the same space.
 
-@defun window-resizable window delta &optional horizontal ignore
+@defun window-resizable window delta &optional horizontal ignore pixelwise
 This function returns @var{delta} if the size of @var{window} can be
 changed vertically by @var{delta} lines.  If the optional argument
 @var{horizontal} is non-@code{nil}, it instead returns @var{delta} if
@@ -596,9 +641,12 @@ Instead, it considers the minimum-height window to be one consisting
 of a header (if any), a mode line, plus a text area one line tall; and
 a minimum-width window as one consisting of fringes, margins, and
 scroll bar (if any), plus a text area two columns wide.
+
+If the optional argument @code{pixelwise} is non-@code{nil},
+@var{delta} will be interpreted as pixels.
 @end defun
 
-@defun window-resize window delta &optional horizontal ignore
+@defun window-resize window delta &optional horizontal ignore pixelwise
 This function resizes @var{window} by @var{delta} increments.  If
 @var{horizontal} is @code{nil}, it changes the height by @var{delta}
 lines; otherwise, it changes the width by @var{delta} columns.  A
@@ -611,6 +659,9 @@ the window cannot be resized as demanded, an error is signaled.
 The optional argument @var{ignore} has the same meaning as for the
 function @code{window-resizable} above.
 
+If the optional argument @code{pixelwise} is non-@code{nil},
+@var{delta} will be interpreted as pixels.
+
 The choice of which window edges this function alters depends on the
 values of the option @code{window-combination-resize} and the
 combination limits of the involved windows; in some cases, it may alter
@@ -623,12 +674,15 @@ bottom or right edge of a window, use the function
 @c shrink-window, and shrink-window-horizontally are documented in the
 @c Emacs manual.  They are not preferred for calling from Lisp.
 
-@defun adjust-window-trailing-edge window delta &optional horizontal
+@defun adjust-window-trailing-edge window delta &optional horizontal pixelwise
 This function moves @var{window}'s bottom edge by @var{delta} lines.
 If optional argument @var{horizontal} is non-@code{nil}, it instead
 moves the right edge by @var{delta} columns.  If @var{window} is
 @code{nil}, it defaults to the selected window.
 
+If the optional argument @code{pixelwise} is non-@code{nil},
+@var{delta} will be interpreted as pixels.
+
 A positive @var{delta} moves the edge downwards or to the right; a
 negative @var{delta} moves it upwards or to the left.  If the edge
 cannot be moved as far as specified by @var{delta}, this function
@@ -639,6 +693,21 @@ moved.  If this is not possible for some reason (e.g., if that adjacent
 window is fixed-size), it may resize other windows.
 @end defun
 
+@cindex pixelwise, resizing windows
+@defopt window-resize-pixelwise
+If the value of this user option is non-@code{nil}, window resizing
+operations will be pixelwise.  This currently affects the following
+functions: @code{split-window}, @code{maximize-window},
+@code{minimize-window}, @code{fit-window-to-buffer} and
+@code{fit-frame-to-buffer}, and all functions that symmetrically
+resize a parent window.
+
+Note that when a frame's pixel size is not a multiple of the frame's
+character size, at least one window may get resized pixelwise even if
+this option is nil.  The default value of this user option is
+@code{nil}.
+@end defopt
+
   The following commands resize windows in more specific ways.  When
 called interactively, they act on the selected window.
 
@@ -2025,6 +2094,15 @@ specified by that entry will override any other window found by the
 methods above, even if that window never showed @var{buffer} before.
 @end defun
 
+@defun display-buffer-at-bottom buffer alist
+This function tries to display @var{buffer} in a window at the bottom
+of the selected frame.
+
+This either splits the window at the bottom of the frame or the
+frame's root window, or reuses an existing window at the bottom of the
+selected frame.
+@end defun
+
 @defun display-buffer-use-some-window buffer alist
 This function tries to display @var{buffer} by choosing an existing
 window and displaying the buffer in that window.  It can fail if all
@@ -3480,6 +3558,7 @@ to clone the state of a frame into an arbitrary live window
 (@code{set-window-configuration} effectively clones the windows of a
 frame into the root window of that very frame only).
 
+@cindex window state
 @defun window-state-get &optional window writable
 This function returns the state of @var{window} as a Lisp object.  The
 argument @var{window} must be a valid window and defaults to the root
@@ -3501,10 +3580,11 @@ written to disk and read back in another session.  In either case, use
 the following function to restore the state of the window.
 
 @defun window-state-put state &optional window ignore
-This function puts the window state @var{state} into @var{window}.  The
-argument @var{state} should be the state of a window returned by an
-earlier invocation of @code{window-state-get}, see above.  The optional
-argument @var{window} must specify a valid window and defaults to the
+This function puts the window state @var{state} into @var{window}.
+The argument @var{state} should be the state of a window returned by
+an earlier invocation of @code{window-state-get}, see above.  The
+optional argument @var{window} can be either a live window or an
+internal window (@pxref{Windows and Frames}) and defaults to the
 selected one.  If @var{window} is not live, it is replaced by a live
 window before putting @var{state} into it.
 
index 2d916b8416cc8d00f39bf0a402c75e1b9188ea56..c7f51b4dcbe7fc238bebcdabf1bfea8335cac919 100644 (file)
@@ -751,6 +751,7 @@ very useful in this case.
 @end itemize
 
 @table @asis
+@c FIXME: This should be `electric-indent-just-newline' since GNU Emacs 24.4.
 @item @kbd{C-j} (@code{newline-and-indent})
 @kindex C-j
 @findex newline-and-indent
@@ -7054,6 +7055,7 @@ Set the variable @code{c-basic-offset}.  @xref{Getting Started}.
 @kindex RET
 @kindex C-j
 @emph{Why doesn't the @kbd{RET} key indent the new line?}
+@c FIXME: `electric-indent-mode' is enabled by default in GNU Emacs 24.4.
 
 Emacs's convention is that @kbd{RET} just adds a newline, and that
 @kbd{C-j} adds a newline and indents it.  You can make @kbd{RET} do this
index 305a54800c103d5b29a12b9cdb89345198ddf569..6dde042a3151e592cf5198862b7af2dda04af835 100644 (file)
@@ -148,6 +148,7 @@ and return values which have to be entered without parentheses
 in one of your Emacs startup files.
 @end table
 
+@c FIXME: `electric-indent-mode' is enabled by default in GNU Emacs 24.4.
 A common problem is that the @key{RET} key does @emph{not} indent the
 line to where the new text should go after inserting the newline.  This
 is because the standard Emacs convention is that @key{RET} (aka
index 90dc3cd8decd194ee0495edce29ed24dbb560773..95f829d14edac25258fa84687ea7ceaa72894320 100644 (file)
@@ -1568,6 +1568,7 @@ Set mark and push previous mark on mark ring (@code{set-mark-command}).
 @kindex 011 TAB (@code{indent-for-tab-command})
 Indent line for current major mode (@code{indent-for-tab-command}).
 @item C-j
+@c FIXME: This should be `electric-indent-just-newline' since GNU Emacs 24.4.
 @kindex 012 @kbd{C-j} (@code{newline-and-indent})
 Insert a newline, then indent according to mode (@code{newline-and-indent}).
 @item C-k
index 3091e8932975d6fecbf4d526a620bb075f9c710e..da19f9c534ba1b102decb8000752a1bea0af4080 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -128,6 +128,7 @@ POSIX ACL interfaces.
 
 ** Multi-monitor support has been added.
 
++++
 *** New functions `display-monitor-attributes-list' and
 `frame-monitor-attributes' can be used to obtain information about
 each physical monitor on multi-monitor setups.
@@ -253,9 +254,11 @@ As a command, it was a special case of `C-x 2' (`split-window-below'),
 and as such superfluous.  After being reimplemented in Lisp, its
 interactive form was mistakenly retained.
 
++++
 *** The functions `window-size' and `window-total-size' now have an
 optional argument to return a rounded size value.
 
++++
 *** `window-state-put' now allows to put a window state into internal
 windows too.
 
@@ -265,10 +268,12 @@ Available only on X, this option allows to control over-scrolling
 using the scroll bar (i.e. dragging the thumb down even when the end
 of the buffer is visible).
 
++++
 *** New basic action function `display-buffer-in-previous-window' has
 `display-buffer' display a buffer in a window previously showing that
 buffer.
 
++++
 *** New basic action function `display-buffer-at-bottom' has
 `display-buffer' choose or make a window at the bottom of the selected
 frame.
index 66514f7488cf9a0536df8c7cdccdba72e13632c7..37e0b7aa1a2d51942a6484ddf37a7ca7e18076e3 100644 (file)
@@ -1,3 +1,27 @@
+2014-02-27  Michael Albinus  <michael.albinus@gmx.de>
+
+       * net/tramp.el (tramp-call-process): Improve trace message.
+       (tramp-handle-insert-file-contents): Trace error case.
+
+       * net/tramp-adb.el (tramp-adb-file-name-handler-alist)
+       <insert-directory>: Use `tramp-handle-insert-directory'.
+       (tramp-adb-handle-insert-directory): Remove function.
+       (tramp-adb-send-command-and-check): New defun, replacing
+       `tramp-adb-command-exit-status'.  Change all callees.
+       (tramp-adb-handle-file-attributes)
+       (tramp-adb-handle-directory-files-and-attributes): Use it.
+       (tramp-adb-ls-output-name-less-p): Use
+       `directory-listing-before-filename-regexp'.
+       (tramp-adb-handle-delete-directory): Flush also file properties of
+       the truename of directory.
+       (tramp-adb-handle-file-name-all-completions): Add "./" and "../".
+       (tramp-adb-handle-file-local-copy): Make the local copy readable.
+       (tramp-adb-handle-write-region): Implement APPEND.
+       (tramp-adb-handle-rename-file): Make it more robust.  Flush file
+       properties correctly.
+       (tramp-adb-maybe-open-connection): Set `tramp-current-*'
+       variables.  Check for connected devices only when needed.
+
 2014-02-27  Glenn Morris  <rgm@gnu.org>
 
        * minibuffer.el (completion-table-dynamic)
index 8f2098c136b565d5e055452bc1632316f279ffd2..4480e4a7189d98e07807c2fd8a33b0cbfd61ecd5 100644 (file)
@@ -38,7 +38,6 @@
 
 ;; Pacify byte-compiler.
 (defvar directory-sep-char)
-(defvar dired-move-to-filename-regexp)
 
 (defcustom tramp-adb-program "adb"
   "Name of the Android Debug Bridge program."
     (find-backup-file-name . tramp-handle-find-backup-file-name)
     ;; `find-file-noselect' performed by default handler.
     ;; `get-file-buffer' performed by default handler.
-    (insert-directory . tramp-adb-handle-insert-directory)
+    (insert-directory . tramp-handle-insert-directory)
     (insert-file-contents . tramp-handle-insert-file-contents)
     (load . tramp-handle-load)
     (make-auto-save-file-name . tramp-handle-make-auto-save-file-name)
@@ -309,17 +308,17 @@ pass to the OPERATION."
 (defun tramp-adb-handle-file-attributes (filename &optional id-format)
   "Like `file-attributes' for Tramp files."
   (unless id-format (setq id-format 'integer))
-  (ignore-errors
-    (with-parsed-tramp-file-name filename nil
-      (with-tramp-file-property
-         v localname (format "file-attributes-%s" id-format)
-       (tramp-adb-barf-unless-okay
-        v (format "%s -d -l %s"
-                  (tramp-adb-get-ls-command v)
-                  (tramp-shell-quote-argument localname)) "")
-       (with-current-buffer (tramp-get-buffer v)
-         (tramp-adb-sh-fix-ls-output)
-         (cdar (tramp-do-parse-file-attributes-with-ls v id-format)))))))
+  (with-parsed-tramp-file-name filename nil
+    (with-tramp-file-property
+       v localname (format "file-attributes-%s" id-format)
+      (and
+       (tramp-adb-send-command-and-check
+       v (format "%s -d -l %s"
+                 (tramp-adb-get-ls-command v)
+                 (tramp-shell-quote-argument localname)))
+       (with-current-buffer (tramp-get-buffer v)
+        (tramp-adb-sh-fix-ls-output)
+        (cdar (tramp-do-parse-file-attributes-with-ls v id-format)))))))
 
 (defun tramp-do-parse-file-attributes-with-ls (vec &optional id-format)
   "Parse `file-attributes' for Tramp files using the ls(1) command."
@@ -366,11 +365,19 @@ pass to the OPERATION."
       (with-tramp-file-property
          v localname (format "directory-files-attributes-%s-%s-%s-%s"
                              full match id-format nosort)
-       (tramp-adb-barf-unless-okay
-        v (format "%s -a -l %s"
-                  (tramp-adb-get-ls-command v)
-                  (tramp-shell-quote-argument localname)) "")
        (with-current-buffer (tramp-get-buffer v)
+         (when (tramp-adb-send-command-and-check
+                v (format "%s -a -l %s"
+                          (tramp-adb-get-ls-command v)
+                          (tramp-shell-quote-argument localname)))
+           ;; We insert also filename/. and filename/.., because "ls" doesn't.
+           (narrow-to-region (point) (point))
+           (tramp-adb-send-command
+            v (format "%s -d -a -l %s %s"
+                      (tramp-adb-get-ls-command v)
+                      (concat (file-name-as-directory localname) ".")
+                      (concat (file-name-as-directory localname) "..")))
+           (widen))
          (tramp-adb-sh-fix-ls-output)
          (let ((result (tramp-do-parse-file-attributes-with-ls
                         v (or id-format 'integer))))
@@ -392,8 +399,7 @@ pass to the OPERATION."
 (defun tramp-adb-get-ls-command (vec)
   (with-tramp-connection-property vec "ls"
     (tramp-message vec 5 "Finding a suitable `ls' command")
-    (if        (zerop (tramp-adb-command-exit-status
-               vec "ls --color=never -al /dev/null"))
+    (if (tramp-adb-send-command-and-check vec "ls --color=never -al /dev/null")
        ;; On CyanogenMod based system BusyBox is used and "ls" output
        ;; coloring is enabled by default.  So we try to disable it
        ;; when possible.
@@ -417,35 +423,6 @@ Convert (\"-al\") to (\"-a\" \"-l\").  Remove arguments like \"--dired\"."
                           (and (not (string-match "\\(^--\\|^[^-]\\)" s)) s))
                         switches))))))
 
-(defun tramp-adb-handle-insert-directory
-  (filename switches &optional _wildcard _full-directory-p)
-  "Like `insert-directory' for Tramp files."
-  (when (stringp switches)
-    (setq switches (tramp-adb--gnu-switches-to-ash (split-string switches))))
-  (with-parsed-tramp-file-name (file-truename filename) nil
-    (with-current-buffer (tramp-get-buffer v)
-      (let ((name (tramp-shell-quote-argument (directory-file-name localname)))
-           (switch-d (member "-d" switches))
-           (switch-t (member "-t" switches))
-           (switches (mapconcat 'identity (remove "-t" switches) " ")))
-       (tramp-adb-barf-unless-okay
-        v (format "%s %s %s" (tramp-adb-get-ls-command v) switches name)
-        "Cannot insert directory listing: %s" filename)
-       (unless switch-d
-         ;; We insert also filename/. and filename/.., because "ls" doesn't.
-         (narrow-to-region (point) (point))
-         (ignore-errors
-           (tramp-adb-barf-unless-okay
-            v (format "%s -d %s %s %s"
-                      (tramp-adb-get-ls-command v)
-                      switches
-                      (concat (file-name-as-directory name) ".")
-                      (concat (file-name-as-directory name) ".."))
-            "Cannot insert directory listing: %s" filename))
-         (widen))
-       (tramp-adb-sh-fix-ls-output switch-t)))
-    (insert-buffer-substring (tramp-get-buffer v))))
-
 (defun tramp-adb-sh-fix-ls-output (&optional sort-by-time)
   "Insert dummy 0 in empty size columns.
 Androids \"ls\" command doesn't insert size column for directories:
@@ -489,9 +466,9 @@ Emacs dired can't find files."
 (defun tramp-adb-ls-output-name-less-p (a b)
   "Sort \"ls\" output by name, ascending."
   (let (posa posb)
-    (string-match dired-move-to-filename-regexp a)
+    (string-match directory-listing-before-filename-regexp a)
     (setq posa (match-end 0))
-    (string-match dired-move-to-filename-regexp b)
+    (string-match directory-listing-before-filename-regexp b)
     (setq posb (match-end 0))
     (string-lessp (substring a posa) (substring b posb))))
 
@@ -511,6 +488,9 @@ Emacs dired can't find files."
 (defun tramp-adb-handle-delete-directory (directory &optional recursive)
   "Like `delete-directory' for Tramp files."
   (setq directory (expand-file-name directory))
+  (with-parsed-tramp-file-name (file-truename directory) nil
+    (tramp-flush-file-property v (file-name-directory localname))
+    (tramp-flush-directory-property v localname))
   (with-parsed-tramp-file-name directory nil
     (tramp-flush-file-property v (file-name-directory localname))
     (tramp-flush-directory-property v localname)
@@ -538,20 +518,22 @@ Emacs dired can't find files."
      (with-tramp-file-property v localname "file-name-all-completions"
        (save-match-data
         (tramp-adb-send-command
-         v (format "%s %s"
+         v (format "%s -a %s"
                    (tramp-adb-get-ls-command v)
                    (tramp-shell-quote-argument localname)))
         (mapcar
          (lambda (f)
-           (if (file-directory-p f)
+           (if (file-directory-p (expand-file-name f directory))
                (file-name-as-directory f)
              f))
          (with-current-buffer (tramp-get-buffer v)
-           (delq
-            nil
-            (mapcar
-             (lambda (l) (and (not (string-match  "^[[:space:]]*$" l)) l))
-             (split-string (buffer-string) "\n"))))))))))
+           (append
+            '("." "..")
+            (delq
+             nil
+             (mapcar
+              (lambda (l) (and (not (string-match  "^[[:space:]]*$" l)) l))
+              (split-string (buffer-string) "\n")))))))))))
 
 (defun tramp-adb-handle-file-local-copy (filename)
   "Like `file-local-copy' for Tramp files."
@@ -567,7 +549,10 @@ Emacs dired can't find files."
          (delete-file tmpfile)
          (tramp-error
           v 'file-error "Cannot make local copy of file `%s'" filename))
-       (set-file-modes tmpfile (file-modes filename)))
+       (set-file-modes
+        tmpfile
+        (logior (or (file-modes filename) 0)
+                (tramp-compat-octal-to-decimal "0400"))))
       tmpfile)))
 
 (defun tramp-adb-handle-file-writable-p (filename)
@@ -577,9 +562,8 @@ But handle the case, if the \"test\" command is not available."
     (with-tramp-file-property v localname "file-writable-p"
       (if (tramp-adb-find-test-command v)
          (if (file-exists-p filename)
-             (zerop
-              (tramp-adb-command-exit-status
-               v (format "test -w %s" (tramp-shell-quote-argument localname))))
+             (tramp-adb-send-command-and-check
+              v (format "test -w %s" (tramp-shell-quote-argument localname)))
            (and
             (file-directory-p (file-name-directory filename))
             (file-writable-p (file-name-directory filename))))
@@ -599,9 +583,6 @@ But handle the case, if the \"test\" command is not available."
   "Like `write-region' for Tramp files."
   (setq filename (expand-file-name filename))
   (with-parsed-tramp-file-name filename nil
-    (when append
-      (tramp-error
-       v 'file-error "Cannot append to file using Tramp (`%s')" filename))
     (when (and confirm (file-exists-p filename))
       (unless (y-or-n-p (format "File %s exists; overwrite anyway? "
                                filename))
@@ -612,6 +593,12 @@ But handle the case, if the \"test\" command is not available."
     (tramp-flush-file-property v localname)
     (let* ((curbuf (current-buffer))
           (tmpfile (tramp-compat-make-temp-file filename)))
+      (when (and append (file-exists-p filename))
+       (copy-file filename tmpfile 'ok)
+       (set-file-modes
+        tmpfile
+        (logior (or (file-modes tmpfile) 0)
+                (tramp-compat-octal-to-decimal "0600"))))
       (tramp-run-real-handler
        'write-region
        (list start end tmpfile append 'no-message lockname confirm))
@@ -645,8 +632,8 @@ But handle the case, if the \"test\" command is not available."
     (let ((time (if (or (null time) (equal time '(0 0)))
                    (current-time)
                  time)))
-      (tramp-adb-command-exit-status
-       ;; use shell arithmetic because of Emacs integer size limit
+      (tramp-adb-send-command-and-check
+       ;; Use shell arithmetic because of Emacs integer size limit.
        v (format "touch -t $(( %d * 65536 + %d )) %s"
                 (car time) (cadr time)
                 (tramp-shell-quote-argument localname))))))
@@ -704,32 +691,36 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
   (setq filename (expand-file-name filename)
        newname (expand-file-name newname))
 
-  (with-parsed-tramp-file-name
-      (if (tramp-tramp-file-p filename) filename newname) nil
-    (with-tramp-progress-reporter
-       v 0 (format "Renaming %s to %s" newname filename)
-
-      (if (and (tramp-equal-remote filename newname)
-              (not (file-directory-p filename)))
-         (progn
-           (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)
-           ;; Short track.
-           (tramp-adb-barf-unless-okay
-            v (format
-               "mv %s %s"
-               (tramp-file-name-handler 'file-remote-p filename 'localname)
-               localname)
-            "Error renaming %s to %s" filename newname))
-
-       ;; Rename by copy.
-       (copy-file filename newname ok-if-already-exists t t)
-       (delete-file filename)))))
+  (let ((t1 (tramp-tramp-file-p filename))
+       (t2 (tramp-tramp-file-p newname)))
+    (with-parsed-tramp-file-name (if t1 filename newname) nil
+      (with-tramp-progress-reporter
+         v 0 (format "Renaming %s to %s" filename newname)
+
+       (if (and t1 t2
+                (tramp-equal-remote filename newname)
+                (not (file-directory-p filename)))
+           (let ((l1 (tramp-file-name-handler
+                      'file-remote-p filename 'localname))
+                 (l2 (tramp-file-name-handler
+                      'file-remote-p newname 'localname)))
+             (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 l1))
+             (tramp-flush-file-property v l1)
+             (tramp-flush-file-property v (file-name-directory l2))
+             (tramp-flush-file-property v l2)
+             ;; Short track.
+             (tramp-adb-barf-unless-okay
+              v (format "mv %s %s" l1 l2)
+              "Error renaming %s to %s" filename newname))
+
+         ;; Rename by copy.
+         (copy-file filename newname ok-if-already-exists t t)
+         (delete-file filename))))))
 
 (defun tramp-adb-handle-process-file
   (program &optional infile destination display &rest args)
@@ -1010,7 +1001,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
   "Checks, whether the ash has a builtin \"test\" command.
 This happens for Android >= 4.0."
   (with-tramp-connection-property vec "test"
-    (zerop (tramp-adb-command-exit-status vec "type test"))))
+    (tramp-adb-send-command-and-check vec "type test")))
 
 ;; Connection functions
 
@@ -1033,9 +1024,9 @@ This happens for Android >= 4.0."
       (while (re-search-forward "\r+$" nil t)
        (replace-match "" nil nil)))))
 
-(defun tramp-adb-command-exit-status
+(defun tramp-adb-send-command-and-check
   (vec command)
-  "Run COMMAND and return its exit status.
+  "Run COMMAND and and check its exit status.
 Sends `echo $?' along with the COMMAND for checking the exit status.  If
 COMMAND is nil, just sends `echo $?'.  Returns the exit status found."
   (tramp-adb-send-command
@@ -1049,14 +1040,14 @@ COMMAND is nil, just sends `echo $?'.  Returns the exit status found."
        vec 'file-error "Couldn't find exit status of `%s'" command))
     (skip-chars-forward "^ ")
     (prog1
-       (read (current-buffer))
+       (zerop (read (current-buffer)))
       (let (buffer-read-only)
        (delete-region (match-beginning 0) (point-max))))))
 
 (defun tramp-adb-barf-unless-okay (vec command fmt &rest args)
   "Run COMMAND, check exit status, throw error if exit status not okay.
 FMT and ARGS are passed to `error'."
-  (unless (zerop (tramp-adb-command-exit-status vec command))
+  (unless (tramp-adb-send-command-and-check vec command)
     (apply 'tramp-error vec 'file-error fmt args)))
 
 (defun tramp-adb-wait-for-output (proc &optional timeout)
@@ -1099,7 +1090,7 @@ connection if a previous connection has died for some reason."
         (p (get-buffer-process buf))
         (host (tramp-file-name-host vec))
         (user (tramp-file-name-user vec))
-        (devices (mapcar 'cadr (tramp-adb-parse-device-names nil))))
+        devices)
 
     ;; Maybe we know already that "su" is not supported.  We cannot
     ;; use a connection property, because we have not checked yet
@@ -1111,6 +1102,10 @@ connection if a previous connection has died for some reason."
        (and p (processp p) (memq (process-status p) '(run open)))
       (save-match-data
        (when (and p (processp p)) (delete-process p))
+       (setq tramp-current-method (tramp-file-name-method vec)
+             tramp-current-user (tramp-file-name-user vec)
+             tramp-current-host (tramp-file-name-host vec)
+             devices (mapcar 'cadr (tramp-adb-parse-device-names nil)))
        (if (not devices)
            (tramp-error vec 'file-error "No device connected"))
        (if (and (> (length host) 0) (not (member host devices)))
@@ -1165,7 +1160,7 @@ connection if a previous connection has died for some reason."
            ;; Change user if indicated.
            (when user
              (tramp-adb-send-command vec (format "su %s" user))
-             (unless (zerop (tramp-adb-command-exit-status vec nil))
+             (unless (tramp-adb-send-command-and-check vec nil)
                (delete-process p)
                (tramp-set-file-property vec "" "su-command-p" nil)
                (tramp-error
index 581aaa40c996384cd77b6bc0cad16ea4eef5cc51..7d88869a0d14b97acf183ccf91e677b91815f970 100644 (file)
@@ -3050,10 +3050,13 @@ User is always nil."
          v 3 (format "Inserting `%s'" filename)
        (unwind-protect
            (if (not (file-exists-p filename))
-               ;; We don't raise a Tramp error, because it might be
-               ;; suppressed, like in `find-file-noselect-1'.
-               (signal 'file-error
-                       (list "File not found on remote host" filename))
+               (progn
+                 ;; We don't raise a Tramp error, because it might be
+                 ;; suppressed, like in `find-file-noselect-1'.
+                 (tramp-message
+                  v 1 "File not `%s' found on remote host" filename)
+                 (signal 'file-error
+                         (list "File not found on remote host" filename)))
 
              (if (and (tramp-local-host-p v)
                       (let (file-name-handler-alist)
@@ -4082,7 +4085,7 @@ Lisp error raised when PROGRAM is nil is trapped also, returning 1.
 Furthermore, traces are written with verbosity of 6."
   (tramp-message
    (vector tramp-current-method tramp-current-user tramp-current-host nil nil)
-   6 "%s %s %s" program infile args)
+   6 "`%s %s' %s" program (mapconcat 'identity args " ") infile)
   (if (executable-find program)
       (apply 'call-process program infile destination display args)
     1))
index cf246b7eda95b00da998993f77437c43d1dd388a..0910f0b15b8bcdc2f77af69a307c5a3b0315863b 100644 (file)
@@ -1,3 +1,24 @@
+2014-02-27  Michael Albinus  <michael.albinus@gmx.de>
+
+       * automated/tramp-tests.el (tramp--test-enabled): Move connection
+       cleanup into this function.  Remove respective code from all test
+       cases.
+       (tramp--instrument-test-case): Declare `indent' and `debug'.
+       Handle other errors as well.
+       (tramp-test14-delete-directory): Check for `file-error' error.
+       (tramp-test15-copy-directory): Ignore return value of
+       `copy-directory'.  It's too much hassle to handle it for tramp-adb.el.
+       (tramp-test19-directory-files-and-attributes): Take care of
+       timestamp of "../".
+       (tramp-test20-file-modes, tramp-test27-start-file-process)
+       (tramp-test28-shell-command): Skip for tramp-adb.el.
+       (tramp-test21-file-links): `file-truename' shall preserve trailing
+       link of directories.
+       (tramp-test22-file-times): Skip if `set-file-times' returns nil.
+       (tramp-test26-process-file, tramp-test28-shell-command): Let-bind
+       `kill-buffer-query-functions' to nil.
+       (tramp-test28-shell-command): Run `async-shell-command' with timeouts.
+
 2014-02-21  Michael Albinus  <michael.albinus@gmx.de>
 
        * automated/tramp-tests.el
index d93fc78f86c89e832408e8b1ec483592d2ecb670..706e2e0e25ea6b40fc348d22c9311cc0a22ca2a9 100644 (file)
@@ -81,6 +81,17 @@ being the result.")
           (file-remote-p tramp-test-temporary-file-directory)
           (file-directory-p tramp-test-temporary-file-directory)
           (file-writable-p tramp-test-temporary-file-directory))))))
+
+  (when (and (cdr tramp--test-enabled-checked)
+            (not (eq (tramp-find-foreign-file-name-handler
+                      tramp-test-temporary-file-directory)
+                     'tramp-adb-file-name-handler)))
+    ;; Cleanup connection.  We don't cleanup for adb, because it
+    ;; doesn't behave well when is disconnect several times.
+    (tramp-cleanup-connection
+     (tramp-dissect-file-name tramp-test-temporary-file-directory)
+     nil 'keep-password))
+
   ;; Return result.
   (cdr tramp--test-enabled-checked))
 
@@ -93,15 +104,21 @@ being the result.")
   "Run BODY with `tramp-verbose' equal VERBOSE.
 Print the the content of the Tramp debug buffer, if BODY does not
 eval properly in `should', `should-not' or `should-error'."
-  `(let ((tramp-verbose ,verbose))
+  (declare (indent 1) (debug (natnump body)))
+  `(let ((tramp-verbose ,verbose)
+        (tramp-debug-on-error t))
      (condition-case err
         (progn ,@body)
-       (ert-test-failed
+       (ert-test-skipped
+       (signal (car err) (cdr err)))
+       (error
        (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil
+         (with-current-buffer (tramp-get-connection-buffer v)
+           (message "%s" (buffer-string)))
          (with-current-buffer (tramp-get-debug-buffer v)
            (message "%s" (buffer-string))))
+       (message "%s" err)
        (signal (car err) (cdr err))))))
-(put 'tramp--instrument-test-case 'lisp-indent-function 1)
 
 (ert-deftest tramp-test00-availability ()
   "Test availability of Tramp functions."
@@ -571,9 +588,6 @@ and `file-name-nondirectory'."
 (ert-deftest tramp-test07-file-exists-p ()
   "Check `file-exist-p', `write-region' and `delete-file'."
   (skip-unless (tramp--test-enabled))
-  (tramp-cleanup-connection
-   (tramp-dissect-file-name tramp-test-temporary-file-directory)
-   nil 'keep-password)
 
   (let ((tmp-name (tramp--test-make-temp-name)))
     (should-not (file-exists-p tmp-name))
@@ -585,9 +599,6 @@ and `file-name-nondirectory'."
 (ert-deftest tramp-test08-file-local-copy ()
   "Check `file-local-copy'."
   (skip-unless (tramp--test-enabled))
-  (tramp-cleanup-connection
-   (tramp-dissect-file-name tramp-test-temporary-file-directory)
-   nil 'keep-password)
 
   (let ((tmp-name1 (tramp--test-make-temp-name))
        tmp-name2)
@@ -605,9 +616,6 @@ and `file-name-nondirectory'."
 (ert-deftest tramp-test09-insert-file-contents ()
   "Check `insert-file-contents'."
   (skip-unless (tramp--test-enabled))
-  (tramp-cleanup-connection
-   (tramp-dissect-file-name tramp-test-temporary-file-directory)
-   nil 'keep-password)
 
   (let ((tmp-name (tramp--test-make-temp-name)))
     (unwind-protect
@@ -629,9 +637,6 @@ and `file-name-nondirectory'."
 (ert-deftest tramp-test10-write-region ()
   "Check `write-region'."
   (skip-unless (tramp--test-enabled))
-  (tramp-cleanup-connection
-   (tramp-dissect-file-name tramp-test-temporary-file-directory)
-   nil 'keep-password)
 
   (let ((tmp-name (tramp--test-make-temp-name)))
     (unwind-protect
@@ -666,9 +671,6 @@ and `file-name-nondirectory'."
 (ert-deftest tramp-test11-copy-file ()
   "Check `copy-file'."
   (skip-unless (tramp--test-enabled))
-  (tramp-cleanup-connection
-   (tramp-dissect-file-name tramp-test-temporary-file-directory)
-   nil 'keep-password)
 
   (let ((tmp-name1 (tramp--test-make-temp-name))
        (tmp-name2 (tramp--test-make-temp-name)))
@@ -687,9 +689,6 @@ and `file-name-nondirectory'."
 (ert-deftest tramp-test12-rename-file ()
   "Check `rename-file'."
   (skip-unless (tramp--test-enabled))
-  (tramp-cleanup-connection
-   (tramp-dissect-file-name tramp-test-temporary-file-directory)
-   nil 'keep-password)
 
   (let ((tmp-name1 (tramp--test-make-temp-name))
        (tmp-name2 (tramp--test-make-temp-name)))
@@ -708,9 +707,6 @@ and `file-name-nondirectory'."
   "Check `make-directory'.
 This tests also `file-directory-p' and `file-accessible-directory-p'."
   (skip-unless (tramp--test-enabled))
-  (tramp-cleanup-connection
-   (tramp-dissect-file-name tramp-test-temporary-file-directory)
-   nil 'keep-password)
 
   (let ((tmp-name (tramp--test-make-temp-name)))
     (unwind-protect
@@ -723,9 +719,6 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
 (ert-deftest tramp-test14-delete-directory ()
   "Check `delete-directory'."
   (skip-unless (tramp--test-enabled))
-  (tramp-cleanup-connection
-   (tramp-dissect-file-name tramp-test-temporary-file-directory)
-   nil 'keep-password)
 
   (let ((tmp-name (tramp--test-make-temp-name)))
     ;; Delete empty directory.
@@ -736,16 +729,13 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
     ;; Delete non-empty directory.
     (make-directory tmp-name)
     (write-region "foo" nil (expand-file-name "bla" tmp-name))
-    (should-error (delete-directory tmp-name))
+    (should-error (delete-directory tmp-name) :type 'file-error)
     (delete-directory tmp-name 'recursive)
     (should-not (file-directory-p tmp-name))))
 
 (ert-deftest tramp-test15-copy-directory ()
   "Check `copy-directory'."
   (skip-unless (tramp--test-enabled))
-  (tramp-cleanup-connection
-   (tramp-dissect-file-name tramp-test-temporary-file-directory)
-   nil 'keep-password)
 
   (let* ((tmp-name1 (tramp--test-make-temp-name))
         (tmp-name2 (tramp--test-make-temp-name))
@@ -761,11 +751,14 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
          (write-region "foo" nil tmp-name4)
          (should (file-directory-p tmp-name1))
          (should (file-exists-p tmp-name4))
-         (copy-directory tmp-name1 tmp-name2)
+         ;; We do not care, whether file permissions and time stamps
+         ;; are correct.  Sometimes, it is not possible to manage
+         ;; them, for example in tramp-adb.el.
+         (ignore-errors (copy-directory tmp-name1 tmp-name2))
          (should (file-directory-p tmp-name2))
          (should (file-exists-p tmp-name5))
          ;; Target directory does exist already.
-         (copy-directory tmp-name1 tmp-name2)
+         (ignore-errors (copy-directory tmp-name1 tmp-name2))
          (should (file-directory-p tmp-name3))
          (should (file-exists-p tmp-name6)))
       (ignore-errors
@@ -775,9 +768,6 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
 (ert-deftest tramp-test16-directory-files ()
   "Check `directory-files'."
   (skip-unless (tramp--test-enabled))
-  (tramp-cleanup-connection
-   (tramp-dissect-file-name tramp-test-temporary-file-directory)
-   nil 'keep-password)
 
   (let* ((tmp-name1 (tramp--test-make-temp-name))
         (tmp-name2 (expand-file-name "bla" tmp-name1))
@@ -806,9 +796,6 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
 (ert-deftest tramp-test17-insert-directory ()
   "Check `insert-directory'."
   (skip-unless (tramp--test-enabled))
-  (tramp-cleanup-connection
-   (tramp-dissect-file-name tramp-test-temporary-file-directory)
-   nil 'keep-password)
 
   (let* ((tmp-name1 (tramp--test-make-temp-name))
         (tmp-name2 (expand-file-name "foo" tmp-name1)))
@@ -844,9 +831,6 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
   "Check `file-attributes'.
 This tests also `file-readable-p' and `file-regular-p'."
   (skip-unless (tramp--test-enabled))
-  (tramp-cleanup-connection
-   (tramp-dissect-file-name tramp-test-temporary-file-directory)
-   nil 'keep-password)
 
   (let ((tmp-name (tramp--test-make-temp-name))
        attr)
@@ -889,39 +873,35 @@ This tests also `file-readable-p' and `file-regular-p'."
 (ert-deftest tramp-test19-directory-files-and-attributes ()
   "Check `directory-files-and-attributes'."
   (skip-unless (tramp--test-enabled))
-  (tramp-cleanup-connection
-   (tramp-dissect-file-name tramp-test-temporary-file-directory)
-   nil 'keep-password)
 
-  (tramp--instrument-test-case 10
-  (let ((tmp-name (tramp--test-make-temp-name))
-       attr)
+  ;; `directory-files-and-attributes' contains also values for "../".
+  ;; We must nesure, that this doesn't change during tests, for
+  ;; example due to handling temporary files.
+  (let* ((tmp-name1 (tramp--test-make-temp-name))
+        (tmp-name2 (expand-file-name "bla" tmp-name1))
+        attr)
     (unwind-protect
        (progn
-         (make-directory tmp-name)
-         (should (file-directory-p tmp-name))
-         (write-region "foo" nil (expand-file-name "foo" tmp-name))
-         (write-region "bar" nil (expand-file-name "bar" tmp-name))
-         (write-region "boz" nil (expand-file-name "boz" tmp-name))
-         (setq attr (directory-files-and-attributes tmp-name))
+         (make-directory tmp-name1)
+         (should (file-directory-p tmp-name1))
+         (make-directory tmp-name2)
+         (should (file-directory-p tmp-name2))
+         (write-region "foo" nil (expand-file-name "foo" tmp-name2))
+         (write-region "bar" nil (expand-file-name "bar" tmp-name2))
+         (write-region "boz" nil (expand-file-name "boz" tmp-name2))
+         (setq attr (directory-files-and-attributes tmp-name2))
          (should (consp attr))
          (dolist (elt attr)
-           ;; We cannot include "." and "..".  They might have
-           ;; changed their timestamp already.
-           (when (string-match "foo$\\|bar$\\|baz$" (car elt))
-             (should
-              (equal (file-attributes (expand-file-name (car elt) tmp-name))
-                     (cdr elt)))))
-         (setq attr (directory-files-and-attributes tmp-name 'full))
+           (should
+            (equal (file-attributes (expand-file-name (car elt) tmp-name2))
+                   (cdr elt))))
+         (setq attr (directory-files-and-attributes tmp-name2 'full))
          (dolist (elt attr)
-           ;; We cannot include "." and "..".  They might have
-           ;; changed their timestamp already.
-           (when (string-match "foo$\\|bar$\\|baz$" (car elt))
-             (should
-              (equal (file-attributes (car elt)) (cdr elt)))))
-         (setq attr (directory-files-and-attributes tmp-name nil "^b"))
+           (should
+            (equal (file-attributes (car elt)) (cdr elt))))
+         (setq attr (directory-files-and-attributes tmp-name2 nil "^b"))
          (should (equal (mapcar 'car attr) '("bar" "boz"))))
-      (ignore-errors (delete-directory tmp-name 'recursive))))))
+      (ignore-errors (delete-directory tmp-name1 'recursive)))))
 
 (ert-deftest tramp-test20-file-modes ()
   "Check `file-modes'.
@@ -931,10 +911,9 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'."
    (not
     (memq
      (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory)
-     '(tramp-gvfs-file-name-handler tramp-smb-file-name-handler))))
-  (tramp-cleanup-connection
-   (tramp-dissect-file-name tramp-test-temporary-file-directory)
-   nil 'keep-password)
+     '(tramp-adb-file-name-handler
+       tramp-gvfs-file-name-handler
+       tramp-smb-file-name-handler))))
 
   (let ((tmp-name (tramp--test-make-temp-name)))
     (unwind-protect
@@ -949,8 +928,7 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'."
          (should (= (file-modes tmp-name) #o444))
          (should-not (file-executable-p tmp-name))
          ;; A file is always writable for user "root".
-         (when (and (stringp (file-remote-p tmp-name 'user))
-                    (not (string-equal (file-remote-p tmp-name 'user) "root")))
+         (when (not (string-equal (file-remote-p tmp-name 'user) "root"))
            (should-not (file-writable-p tmp-name))))
       (ignore-errors (delete-file tmp-name)))))
 
@@ -958,9 +936,6 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'."
   "Check `file-symlink-p'.
 This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
   (skip-unless (tramp--test-enabled))
-  (tramp-cleanup-connection
-   (tramp-dissect-file-name tramp-test-temporary-file-directory)
-   nil 'keep-password)
 
   (let ((tmp-name1 (tramp--test-make-temp-name))
        (tmp-name2 (tramp--test-make-temp-name))
@@ -1014,7 +989,13 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
           (string-equal (file-truename tmp-name1) (file-truename tmp-name2))))
       (ignore-errors
        (delete-file tmp-name1)
-       (delete-file tmp-name2)))))
+       (delete-file tmp-name2)))
+
+    ;; `file-truename' shall preserve trailing link of directories.
+    (let* ((dir1 (directory-file-name tramp-test-temporary-file-directory))
+          (dir2 (file-name-as-directory dir1)))
+      (should (string-equal (file-truename dir1) (expand-file-name dir1)))
+      (should (string-equal (file-truename dir2) (expand-file-name dir2))))))
 
 (ert-deftest tramp-test22-file-times ()
   "Check `set-file-times' and `file-newer-than-file-p'."
@@ -1024,9 +1005,6 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
     (memq
      (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory)
      '(tramp-gvfs-file-name-handler tramp-smb-file-name-handler))))
-  (tramp-cleanup-connection
-   (tramp-dissect-file-name tramp-test-temporary-file-directory)
-   nil 'keep-password)
 
   (let ((tmp-name1 (tramp--test-make-temp-name))
        (tmp-name2 (tramp--test-make-temp-name))
@@ -1036,8 +1014,11 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
          (write-region "foo" nil tmp-name1)
          (should (file-exists-p tmp-name1))
          (should (consp (nth 5 (file-attributes tmp-name1))))
-         ;; '(0 0) means don't know, and will be replaced by `current-time'.
-         (set-file-times tmp-name1 '(0 1))
+         ;; '(0 0) means don't know, and will be replaced by
+         ;; `current-time'.  Therefore, we use '(0 1).
+         ;; We skip the test, if the remote handler is not able to
+         ;; set the correct time.
+         (skip-unless (set-file-times tmp-name1 '(0 1)))
          ;; Dumb busyboxes are not able to return the date correctly.
          ;; They say "don't know.
          (skip-unless (not (equal (nth 5 (file-attributes tmp-name1)) '(0 0))))
@@ -1055,9 +1036,6 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
 (ert-deftest tramp-test23-visited-file-modtime ()
   "Check `set-visited-file-modtime' and `verify-visited-file-modtime'."
   (skip-unless (tramp--test-enabled))
-  (tramp-cleanup-connection
-   (tramp-dissect-file-name tramp-test-temporary-file-directory)
-   nil 'keep-password)
 
   (let ((tmp-name (tramp--test-make-temp-name)))
     (unwind-protect
@@ -1075,9 +1053,6 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
 (ert-deftest tramp-test24-file-name-completion ()
   "Check `file-name-completion' and `file-name-all-completions'."
   (skip-unless (tramp--test-enabled))
-  (tramp-cleanup-connection
-   (tramp-dissect-file-name tramp-test-temporary-file-directory)
-   nil 'keep-password)
 
   (let ((tmp-name (tramp--test-make-temp-name)))
     (unwind-protect
@@ -1100,9 +1075,6 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
 (ert-deftest tramp-test25-load ()
   "Check `load'."
   (skip-unless (tramp--test-enabled))
-  (tramp-cleanup-connection
-   (tramp-dissect-file-name tramp-test-temporary-file-directory)
-   nil 'keep-password)
 
   (let ((tmp-name (tramp--test-make-temp-name)))
     (unwind-protect
@@ -1126,12 +1098,10 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
     (memq
      (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory)
      '(tramp-gvfs-file-name-handler tramp-smb-file-name-handler))))
-  (tramp-cleanup-connection
-   (tramp-dissect-file-name tramp-test-temporary-file-directory)
-   nil 'keep-password)
 
   (let ((tmp-name (tramp--test-make-temp-name))
-       (default-directory tramp-test-temporary-file-directory))
+       (default-directory tramp-test-temporary-file-directory)
+       kill-buffer-query-functions)
     (unwind-protect
        (progn
          ;; We cannot use "/bin/true" and "/bin/false"; those paths
@@ -1162,10 +1132,9 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
    (not
     (memq
      (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory)
-     '(tramp-gvfs-file-name-handler tramp-smb-file-name-handler))))
-  (tramp-cleanup-connection
-   (tramp-dissect-file-name tramp-test-temporary-file-directory)
-   nil 'keep-password)
+     '(tramp-adb-file-name-handler
+       tramp-gvfs-file-name-handler
+       tramp-smb-file-name-handler))))
 
   (let ((default-directory tramp-test-temporary-file-directory)
        (tmp-name (tramp--test-make-temp-name))
@@ -1215,13 +1184,13 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
    (not
     (memq
      (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory)
-     '(tramp-gvfs-file-name-handler tramp-smb-file-name-handler))))
-  (tramp-cleanup-connection
-   (tramp-dissect-file-name tramp-test-temporary-file-directory)
-   nil 'keep-password)
+     '(tramp-adb-file-name-handler
+       tramp-gvfs-file-name-handler
+       tramp-smb-file-name-handler))))
 
   (let ((tmp-name (tramp--test-make-temp-name))
-       (default-directory tramp-test-temporary-file-directory))
+       (default-directory tramp-test-temporary-file-directory)
+       kill-buffer-query-functions)
     (unwind-protect
        (with-temp-buffer
          (write-region "foo" nil tmp-name)
@@ -1244,10 +1213,12 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
           (async-shell-command
           (format "ls %s" (file-name-nondirectory tmp-name)) (current-buffer))
          (accept-process-output (get-buffer-process (current-buffer)) 1)
-         (while (ignore-errors
-                  (memq (process-status (get-buffer-process (current-buffer)))
-                        '(run open)))
-           (accept-process-output (get-buffer-process (current-buffer)) 1))
+         (with-timeout (10 (ert-fail "`async-shell-command' timed out"))
+           (while
+               (ignore-errors
+                 (memq (process-status (get-buffer-process (current-buffer)))
+                       '(run open)))
+             (accept-process-output (get-buffer-process (current-buffer)) 1)))
          ;; `ls' could produce colorized output.
          (goto-char (point-min))
          (while (re-search-forward tramp-color-escape-sequence-regexp nil t)
@@ -1266,10 +1237,12 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
           (get-buffer-process (current-buffer))
           (format "%s\n" (file-name-nondirectory tmp-name)))
          (accept-process-output (get-buffer-process (current-buffer)) 1)
-         (while (ignore-errors
-                  (memq (process-status (get-buffer-process (current-buffer)))
-                        '(run open)))
-           (accept-process-output (get-buffer-process (current-buffer)) 1))
+         (with-timeout (10 (ert-fail "`async-shell-command' timed out"))
+           (while
+               (ignore-errors
+                 (memq (process-status (get-buffer-process (current-buffer)))
+                       '(run open)))
+             (accept-process-output (get-buffer-process (current-buffer)) 1)))
          (should
           (string-equal
            (format "%s\n" (file-name-nondirectory tmp-name)) (buffer-string))))
@@ -1282,9 +1255,6 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
    (eq
     (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory)
     'tramp-sh-file-name-handler))
-  (tramp-cleanup-connection
-   (tramp-dissect-file-name tramp-test-temporary-file-directory)
-   nil 'keep-password)
 
   (let* ((default-directory tramp-test-temporary-file-directory)
         (tmp-name1 (tramp--test-make-temp-name))
@@ -1326,9 +1296,6 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
 (ert-deftest tramp-test30-utf8 ()
   "Check UTF8 encoding in file names and file contents."
   (skip-unless (tramp--test-enabled))
-  (tramp-cleanup-connection
-   (tramp-dissect-file-name tramp-test-temporary-file-directory)
-   nil 'keep-password)
 
   (let ((tmp-name (tramp--test-make-temp-name))
        (coding-system-for-read 'utf-8)