* 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.
+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):
@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,
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
@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)}
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
@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
@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 :
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.
@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
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
@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
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
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
@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.
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.
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
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
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
@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
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.
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
(@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
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.
@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
@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
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
@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
** 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.
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.
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.
+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)
;; 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)
(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."
(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))))
(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.
(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:
(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))))
(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)
(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."
(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)
(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))))
"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))
(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))
(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))))))
(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)
"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
(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
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)
(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
(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)))
;; 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
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)
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))
+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
(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))
"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."
(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))
(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)
(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
(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
(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)))
(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)))
"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
(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.
;; 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))
(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
(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))
(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)))
"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)
(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'.
(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
(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)))))
"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))
(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'."
(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))
(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))))
(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
(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
(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
(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
(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))
(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)
(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)
(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))))
(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))
(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)