Commit 20b8ac83 authored by Michael Albinus's avatar Michael Albinus

Sync with Tramp 2.1.19.

* net/tramp-cmds.el (tramp-cleanup-all-connections)
(tramp-reporter-dump-variable, tramp-load-report-modules)
(tramp-append-tramp-buffers): Use `tramp-compat-funcall'.
(tramp-bug): Recommend setting of `tramp-verbose' to 9.

* net/tramp-compat.el (top): Do not autoload
`tramp-handle-file-remote-p'.  Load tramp-util.el and tramp-vc.el
only when `start-file-process' is not bound.
(byte-compile-not-obsolete-vars): Define if not bound.
(tramp-compat-funcall): New defmacro.
(tramp-compat-line-beginning-position)
(tramp-compat-line-end-position)
(tramp-compat-temporary-file-directory)
(tramp-compat-make-temp-file, tramp-compat-file-attributes)
(tramp-compat-copy-file, tramp-compat-copy-directory)
(tramp-compat-delete-file, tramp-compat-delete-directory)
(tramp-compat-number-sequence, tramp-compat-process-running-p):
Use it.
(tramp-advice-file-expand-wildcards): Do not use
`tramp-handle-file-remote-p'.
(tramp-compat-make-temp-file): Simplify fallback implementation.
(tramp-compat-copy-file): Add PRESERVE-SELINUX-CONTEXT.
(tramp-compat-copy-tree): Remove function.
(tramp-compat-delete-file): New defun.
(tramp-compat-delete-directory): Provide implementation for older
Emacsen.
(tramp-compat-file-attributes): Handle only
`wrong-number-of-arguments' error.

* net/tramp-fish.el (tramp-fish-handle-copy-file): Add
PRESERVE_SELINUX_CONTEXT.
(tramp-fish-handle-delete-file): Add TRASH arg.
(tramp-fish-handle-directory-files-and-attributes):
Do not use `tramp-fish-handle-file-attributes.
(tramp-fish-handle-file-local-copy)
(tramp-fish-handle-insert-file-contents)
(tramp-fish-maybe-open-connection): Use `with-progress-reporter'.

* net/tramp-gvfs.el (top): Require url-util.
(tramp-gvfs-mount-point): Remove.
(tramp-gvfs-file-name-handler-alist): Add `file-selinux-context'
and `set-file-selinux-context'.
(tramp-gvfs-stringify-dbus-message, tramp-gvfs-send-command)
(tramp-gvfs-handle-file-selinux-context)
(tramp-gvfs-handle-set-file-selinux-context): New defuns.
(with-tramp-dbus-call-method): Format trace message.
(tramp-gvfs-handle-copy-file): Handle PRESERVE-SELINUX-CONTEXT.
(tramp-gvfs-handle-copy-file, tramp-gvfs-handle-rename-file):
Implement backup call, when operation on local files fails.  Use
progress reporter.  Flush properties of changed files.
(tramp-gvfs-handle-delete-file): Add TRASH arg.  Use
`tramp-compat-delete-file'.
(tramp-gvfs-handle-expand-file-name): Expand "~/".
(tramp-gvfs-handle-make-directory): Make more traces.
(tramp-gvfs-handle-write-region): Protect deleting tmpfile.
(tramp-gvfs-url-file-name): Hexify file name in url.
(tramp-gvfs-fuse-file-name): Take also prefix (like dav shares)
into account for the resulting file name.
(tramp-gvfs-handler-askquestion): Preserve current message, in
order to let progress reporter continue afterwards.  (Bug#6257)
Return dummy mountpoint, when the answer is "no".  See
`tramp-gvfs-maybe-open-connection'.
(tramp-gvfs-handler-mounted-unmounted)
(tramp-gvfs-connection-mounted-p): Test also for new mountspec
attribute "default_location".  Set "prefix" property.  Handle
default-location.
(tramp-gvfs-mount-spec): Return both prefix and mountspec.
(tramp-gvfs-maybe-open-connection): Test, whether mountpoint
exists.  Raise an error, if not (due to a corresponding answer
"no" in interactive questions, for example). Use
`tramp-compat-funcall'.

* net/tramp-imap.el (top): Autoload `epg-make-context'.
(tramp-imap-handle-copy-file): Add PRESERVE-SELINUX-CONTEXT.
(tramp-imap-do-copy-or-rename-file)
(tramp-imap-handle-insert-file-contents)
(tramp-imap-handle-file-local-copy): Use `with-progress-reporter'.
(tramp-imap-handle-delete-file): Add TRASH arg.

* net/tramp-smb.el (tramp-smb-handle-copy-file): Add
PRESERVE-SELINUX-CONTEXT.
(tramp-smb-handle-copy-file)
(tramp-smb-handle-file-local-copy, tramp-smb-handle-rename-file)
(tramp-smb-handle-write-region, tramp-smb-maybe-open-connection):
Use `with-progress-reporter'.
(tramp-smb-handle-delete-file): Add TRASH arg.

* net/tramp.el (tramp-methods): Move hostname to the end in all
ssh `tramp-login-args'.  Add `tramp-async-args' attribute where
appropriate.
(tramp-verbose): Describe verbose level 9.
(tramp-completion-function-alist)
(tramp-file-name-regexp, tramp-chunksize)
(tramp-local-coding-commands, tramp-remote-coding-commands)
(with-connection-property, tramp-completion-mode-p)
(tramp-action-process-alive, tramp-action-out-of-band)
(tramp-check-for-regexp, tramp-file-name-p, tramp-equal-remote)
(tramp-exists-file-name-handler): Fix docstring.
(tramp-remote-process-environment): Use `format' instead of
`concat'.  Protect version string by apostroph.
(tramp-shell-prompt-pattern): Do not use a shy group in case of
XEmacs.
(tramp-file-name-regexp-unified)
(tramp-completion-file-name-regexp-unified): On W32 systems, do
not regard the volume letter as remote filename.  (Bug#5447)
(tramp-perl-file-attributes)
(tramp-perl-directory-files-and-attributes): Don't pass "$3".
(tramp-vc-registered-read-file-names): Read input as
here-document, otherwise the command could exceed maximum length
of command line.
(tramp-file-name-handler-alist): Add `file-selinux-context' and
`set-file-selinux-context'.
(tramp-debug-message): Add `tramp-compat-funcall' to ignored
backtrace functions.
(tramp-error-with-buffer): Don't show the connection buffer when
we are in completion mode.
(tramp-progress-reporter-update, tramp-remote-selinux-p)
(tramp-handle-file-selinux-context)
(tramp-handle-set-file-selinux-context, tramp-process-sentinel)
(tramp-connectable-p, tramp-open-shell, tramp-get-remote-trash):
New defuns.
(with-progress-reporter): New defmacro.
(tramp-debug-outline-regexp): New defconst.
(top, tramp-rfn-eshadow-setup-minibuffer)
(tramp-rfn-eshadow-update-overlay, tramp-handle-set-file-times)
(tramp-handle-dired-compress-file, tramp-handle-shell-command)
(tramp-completion-mode-p, tramp-check-for-regexp)
(tramp-open-connection-setup-interactive-shell)
(tramp-compute-multi-hops, tramp-read-passwd, tramp-clear-passwd)
(tramp-time-diff, tramp-coding-system-change-eol-conversion)
(tramp-set-process-query-on-exit-flag, tramp-unload-tramp):
Use `tramp-compat-funcall'.
(tramp-handle-make-symbolic-link): Flush file properties.
(tramp-handle-load, tramp-handle-file-local-copy)
(tramp-handle-insert-file-contents, tramp-handle-write-region)
(tramp-handle-vc-registered, tramp-maybe-send-script)
(tramp-find-shell): Use `with-progress-reporter'.
(tramp-do-file-attributes-with-stat): Add space in format string,
in order to work around a bug in pdksh.  Reported by Gilles Pion
<gpion@lfdj.com>.
(tramp-handle-verify-visited-file-modtime): Do not send a command
when the connection is not established.
(tramp-handle-set-file-times): Simplify the check for utc.
(tramp-handle-directory-files-and-attributes)
(tramp-get-remote-path): Use `copy-tree'.
(tramp-completion-handle-file-name-all-completions): Ensure, that
non remote files are still checked.  Oops.
(tramp-handle-copy-file, tramp-do-copy-or-rename-file): Handle
PRESERVE-SELINUX-CONTEXT.
(tramp-do-copy-or-rename-file): Add progress reporter.
(tramp-do-copy-or-rename-file-directly): Do not use
`tramp-handle-file-remote-p'.
(tramp-do-copy-or-rename-file-out-of-band):
Use `tramp-compat-delete-directory'.
(tramp-do-copy-or-rename-file-out-of-band)
(tramp-compute-multi-hops, tramp-maybe-open-connection):
Use `format-spec-make'.
(tramp-handle-delete-file): Add TRASH arg.
(tramp-handle-dired-uncache): Flush directory cache, not only file
cache.
(tramp-handle-expand-file-name)
(tramp-completion-handle-file-name-all-completions)
(tramp-completion-handle-file-name-completion): Use
`tramp-connectable-p'.
(tramp-handle-start-file-process): Set connection property "vec".
Use it, in order to invalidate file caches.  Check only for
`remote-tty' process property.
Implement tty setting.  (Bug#4604, Bug#6360)
(tramp-file-name-for-operation): Add `call-process-region' and
`set-file-selinux-context'.
(tramp-find-foreign-file-name-handler)
(tramp-advice-make-auto-save-file-name)
(tramp-set-auto-save-file-modes): Remove superfluous check for
`stringp'.  This is done inside `tramp-tramp-file-p'.
(tramp-file-name-handler): Trace 'quit.  Catch the error for some
operations when we are in completion mode.  This gives the user
the chance to correct the file name in the minibuffer.
(tramp-completion-mode-p): Use `non-essential'.
(tramp-handle-file-name-all-completions): Backward/ XEmacs
compatibility: Use `completion-ignore-case' if
`read-file-name-completion-ignore-case' does not exist.
(tramp-get-debug-buffer): Use `tramp-debug-outline-regexp'.
(tramp-find-shell, tramp-open-connection-setup-interactive-shell):
`tramp-open-shell'.
(tramp-action-password): Hide password prompt before next run.
(tramp-process-actions): Widen connection buffer for the trace.
(tramp-open-connection-setup-interactive-shell): Set `remote-tty'
process property.  Trace stty settings if `tramp-verbose' >= 9.
Apply workaround for IRIX64 bug.  Move argument of last
`tramp-send-command' where it belongs to.
(tramp-maybe-open-connection): Use `async-args' and `gw-args' in
front of `login-args'.
(tramp-get-ls-command, tramp-get-ls-command-with-dired): Run tests
on "/dev/null" instead of "/".
(tramp-get-ls-command-with-dired): Make test for "--dired"
stronger.
(tramp-set-auto-save-file-modes): Adapt version check.
(tramp-set-process-query-on-exit-flag): Fix wrong parentheses.
(tramp-handle-process-file): Call the program in a subshell, in
order to preserve working directory.
(tramp-handle-shell-command): Don't use hard-wired "/bin/sh" but
`tramp-remote-sh' from `tramp-methods'.
(tramp-get-ls-command): Make test for "--color=never" stronger.
(tramp-check-for-regexp): Use (forward-line 1).

* net/trampver.el: Update release number.

* net/tramp-gvfs.el (tramp-gvfs-handle-copy-file): Do not pass
empty argument to gvfs-copy.

* net/tramp-compat.el (tramp-compat-delete-file): Rewrite to
handle new TRASH arg of `delete-file'.

* net/tramp.el (tramp-handle-insert-directory): Don't use
`forward-word', its default syntax could be changed.

Implement compression for inline methods.

* net/tramp.el (tramp-inline-compress-start-size): New defcustom.
(tramp-copy-size-limit): Allow also nil.
(tramp-inline-compress-commands): New defconst.
(tramp-find-inline-compress, tramp-get-inline-compress)
(tramp-get-inline-coding): New defuns.
(tramp-get-remote-coding, tramp-get-local-coding): Remove,
replaced by `tramp-get-inline-coding'.
(tramp-handle-file-local-copy, tramp-handle-write-region)
(tramp-method-out-of-band-p): Use `tramp-get-inline-coding'.

Detect ssh 'ControlMaster' argument automatically in some cases.

* net/tramp.el (tramp-detect-ssh-controlmaster): New defun.
(tramp-default-method): Use it.

* net/tramp.el (tramp-file-name-for-operation):
Add file-selinux-context.
parent d5720b4c
2010-08-26 Michael Albinus <michael.albinus@gmx.de>
Sync with Tramp 2.1.19.
* net/tramp-cmds.el (tramp-cleanup-all-connections)
(tramp-reporter-dump-variable, tramp-load-report-modules)
(tramp-append-tramp-buffers): Use `tramp-compat-funcall'.
(tramp-bug): Recommend setting of `tramp-verbose' to 9.
* net/tramp-compat.el (top): Do not autoload
`tramp-handle-file-remote-p'. Load tramp-util.el and tramp-vc.el
only when `start-file-process' is not bound.
(byte-compile-not-obsolete-vars): Define if not bound.
(tramp-compat-funcall): New defmacro.
(tramp-compat-line-beginning-position)
(tramp-compat-line-end-position)
(tramp-compat-temporary-file-directory)
(tramp-compat-make-temp-file, tramp-compat-file-attributes)
(tramp-compat-copy-file, tramp-compat-copy-directory)
(tramp-compat-delete-file, tramp-compat-delete-directory)
(tramp-compat-number-sequence, tramp-compat-process-running-p):
Use it.
(tramp-advice-file-expand-wildcards): Do not use
`tramp-handle-file-remote-p'.
(tramp-compat-make-temp-file): Simplify fallback implementation.
(tramp-compat-copy-file): Add PRESERVE-SELINUX-CONTEXT.
(tramp-compat-copy-tree): Remove function.
(tramp-compat-delete-file): New defun.
(tramp-compat-delete-directory): Provide implementation for older
Emacsen.
(tramp-compat-file-attributes): Handle only
`wrong-number-of-arguments' error.
* net/tramp-fish.el (tramp-fish-handle-copy-file): Add
PRESERVE_SELINUX_CONTEXT.
(tramp-fish-handle-delete-file): Add TRASH arg.
(tramp-fish-handle-directory-files-and-attributes):
Do not use `tramp-fish-handle-file-attributes.
(tramp-fish-handle-file-local-copy)
(tramp-fish-handle-insert-file-contents)
(tramp-fish-maybe-open-connection): Use `with-progress-reporter'.
* net/tramp-gvfs.el (top): Require url-util.
(tramp-gvfs-mount-point): Remove.
(tramp-gvfs-file-name-handler-alist): Add `file-selinux-context'
and `set-file-selinux-context'.
(tramp-gvfs-stringify-dbus-message, tramp-gvfs-send-command)
(tramp-gvfs-handle-file-selinux-context)
(tramp-gvfs-handle-set-file-selinux-context): New defuns.
(with-tramp-dbus-call-method): Format trace message.
(tramp-gvfs-handle-copy-file): Handle PRESERVE-SELINUX-CONTEXT.
(tramp-gvfs-handle-copy-file, tramp-gvfs-handle-rename-file):
Implement backup call, when operation on local files fails. Use
progress reporter. Flush properties of changed files.
(tramp-gvfs-handle-delete-file): Add TRASH arg. Use
`tramp-compat-delete-file'.
(tramp-gvfs-handle-expand-file-name): Expand "~/".
(tramp-gvfs-handle-make-directory): Make more traces.
(tramp-gvfs-handle-write-region): Protect deleting tmpfile.
(tramp-gvfs-url-file-name): Hexify file name in url.
(tramp-gvfs-fuse-file-name): Take also prefix (like dav shares)
into account for the resulting file name.
(tramp-gvfs-handler-askquestion): Preserve current message, in
order to let progress reporter continue afterwards. (Bug#6257)
Return dummy mountpoint, when the answer is "no". See
`tramp-gvfs-maybe-open-connection'.
(tramp-gvfs-handler-mounted-unmounted)
(tramp-gvfs-connection-mounted-p): Test also for new mountspec
attribute "default_location". Set "prefix" property. Handle
default-location.
(tramp-gvfs-mount-spec): Return both prefix and mountspec.
(tramp-gvfs-maybe-open-connection): Test, whether mountpoint
exists. Raise an error, if not (due to a corresponding answer
"no" in interactive questions, for example). Use
`tramp-compat-funcall'.
* net/tramp-imap.el (top): Autoload `epg-make-context'.
(tramp-imap-handle-copy-file): Add PRESERVE-SELINUX-CONTEXT.
(tramp-imap-do-copy-or-rename-file)
(tramp-imap-handle-insert-file-contents)
(tramp-imap-handle-file-local-copy): Use `with-progress-reporter'.
(tramp-imap-handle-delete-file): Add TRASH arg.
* net/tramp-smb.el (tramp-smb-handle-copy-file): Add
PRESERVE-SELINUX-CONTEXT.
(tramp-smb-handle-copy-file)
(tramp-smb-handle-file-local-copy, tramp-smb-handle-rename-file)
(tramp-smb-handle-write-region, tramp-smb-maybe-open-connection):
Use `with-progress-reporter'.
(tramp-smb-handle-delete-file): Add TRASH arg.
* net/tramp.el (tramp-methods): Move hostname to the end in all
ssh `tramp-login-args'. Add `tramp-async-args' attribute where
appropriate.
(tramp-verbose): Describe verbose level 9.
(tramp-completion-function-alist)
(tramp-file-name-regexp, tramp-chunksize)
(tramp-local-coding-commands, tramp-remote-coding-commands)
(with-connection-property, tramp-completion-mode-p)
(tramp-action-process-alive, tramp-action-out-of-band)
(tramp-check-for-regexp, tramp-file-name-p, tramp-equal-remote)
(tramp-exists-file-name-handler): Fix docstring.
(tramp-remote-process-environment): Use `format' instead of
`concat'. Protect version string by apostroph.
(tramp-shell-prompt-pattern): Do not use a shy group in case of
XEmacs.
(tramp-file-name-regexp-unified)
(tramp-completion-file-name-regexp-unified): On W32 systems, do
not regard the volume letter as remote filename. (Bug#5447)
(tramp-perl-file-attributes)
(tramp-perl-directory-files-and-attributes): Don't pass "$3".
(tramp-vc-registered-read-file-names): Read input as
here-document, otherwise the command could exceed maximum length
of command line.
(tramp-file-name-handler-alist): Add `file-selinux-context' and
`set-file-selinux-context'.
(tramp-debug-message): Add `tramp-compat-funcall' to ignored
backtrace functions.
(tramp-error-with-buffer): Don't show the connection buffer when
we are in completion mode.
(tramp-progress-reporter-update, tramp-remote-selinux-p)
(tramp-handle-file-selinux-context)
(tramp-handle-set-file-selinux-context, tramp-process-sentinel)
(tramp-connectable-p, tramp-open-shell, tramp-get-remote-trash):
New defuns.
(with-progress-reporter): New defmacro.
(tramp-debug-outline-regexp): New defconst.
(top, tramp-rfn-eshadow-setup-minibuffer)
(tramp-rfn-eshadow-update-overlay, tramp-handle-set-file-times)
(tramp-handle-dired-compress-file, tramp-handle-shell-command)
(tramp-completion-mode-p, tramp-check-for-regexp)
(tramp-open-connection-setup-interactive-shell)
(tramp-compute-multi-hops, tramp-read-passwd, tramp-clear-passwd)
(tramp-time-diff, tramp-coding-system-change-eol-conversion)
(tramp-set-process-query-on-exit-flag, tramp-unload-tramp):
Use `tramp-compat-funcall'.
(tramp-handle-make-symbolic-link): Flush file properties.
(tramp-handle-load, tramp-handle-file-local-copy)
(tramp-handle-insert-file-contents, tramp-handle-write-region)
(tramp-handle-vc-registered, tramp-maybe-send-script)
(tramp-find-shell): Use `with-progress-reporter'.
(tramp-do-file-attributes-with-stat): Add space in format string,
in order to work around a bug in pdksh. Reported by Gilles Pion
<gpion@lfdj.com>.
(tramp-handle-verify-visited-file-modtime): Do not send a command
when the connection is not established.
(tramp-handle-set-file-times): Simplify the check for utc.
(tramp-handle-directory-files-and-attributes)
(tramp-get-remote-path): Use `copy-tree'.
(tramp-completion-handle-file-name-all-completions): Ensure, that
non remote files are still checked. Oops.
(tramp-handle-copy-file, tramp-do-copy-or-rename-file): Handle
PRESERVE-SELINUX-CONTEXT.
(tramp-do-copy-or-rename-file): Add progress reporter.
(tramp-do-copy-or-rename-file-directly): Do not use
`tramp-handle-file-remote-p'.
(tramp-do-copy-or-rename-file-out-of-band):
Use `tramp-compat-delete-directory'.
(tramp-do-copy-or-rename-file-out-of-band)
(tramp-compute-multi-hops, tramp-maybe-open-connection):
Use `format-spec-make'.
(tramp-handle-delete-file): Add TRASH arg.
(tramp-handle-dired-uncache): Flush directory cache, not only file
cache.
(tramp-handle-expand-file-name)
(tramp-completion-handle-file-name-all-completions)
(tramp-completion-handle-file-name-completion): Use
`tramp-connectable-p'.
(tramp-handle-start-file-process): Set connection property "vec".
Use it, in order to invalidate file caches. Check only for
`remote-tty' process property.
Implement tty setting. (Bug#4604, Bug#6360)
(tramp-file-name-for-operation): Add `call-process-region' and
`set-file-selinux-context'.
(tramp-find-foreign-file-name-handler)
(tramp-advice-make-auto-save-file-name)
(tramp-set-auto-save-file-modes): Remove superfluous check for
`stringp'. This is done inside `tramp-tramp-file-p'.
(tramp-file-name-handler): Trace 'quit. Catch the error for some
operations when we are in completion mode. This gives the user
the chance to correct the file name in the minibuffer.
(tramp-completion-mode-p): Use `non-essential'.
(tramp-handle-file-name-all-completions): Backward/ XEmacs
compatibility: Use `completion-ignore-case' if
`read-file-name-completion-ignore-case' does not exist.
(tramp-get-debug-buffer): Use `tramp-debug-outline-regexp'.
(tramp-find-shell, tramp-open-connection-setup-interactive-shell):
`tramp-open-shell'.
(tramp-action-password): Hide password prompt before next run.
(tramp-process-actions): Widen connection buffer for the trace.
(tramp-open-connection-setup-interactive-shell): Set `remote-tty'
process property. Trace stty settings if `tramp-verbose' >= 9.
Apply workaround for IRIX64 bug. Move argument of last
`tramp-send-command' where it belongs to.
(tramp-maybe-open-connection): Use `async-args' and `gw-args' in
front of `login-args'.
(tramp-get-ls-command, tramp-get-ls-command-with-dired): Run tests
on "/dev/null" instead of "/".
(tramp-get-ls-command-with-dired): Make test for "--dired"
stronger.
(tramp-set-auto-save-file-modes): Adapt version check.
(tramp-set-process-query-on-exit-flag): Fix wrong parentheses.
(tramp-handle-process-file): Call the program in a subshell, in
order to preserve working directory.
(tramp-handle-shell-command): Don't use hard-wired "/bin/sh" but
`tramp-remote-sh' from `tramp-methods'.
(tramp-get-ls-command): Make test for "--color=never" stronger.
(tramp-check-for-regexp): Use (forward-line 1).
* net/trampver.el: Update release number.
2010-08-26 Magnus Henoch <magnus.henoch@gmail.com>
* net/tramp-gvfs.el (tramp-gvfs-handle-copy-file): Do not pass
empty argument to gvfs-copy.
2010-08-26 Chong Yidong <cyd@stupidchicken.com>
* net/tramp-compat.el (tramp-compat-delete-file): Rewrite to
handle new TRASH arg of `delete-file'.
2010-08-26 Christian Lynbech <christian.lynbech@tieto.com> (tiny change)
* net/tramp.el (tramp-handle-insert-directory): Don't use
`forward-word', its default syntax could be changed.
2010-08-26 Toru TSUNEYOSHI <t_tuneyosi@hotmail.com>
Michael Albinus <michael.albinus@gmx.de>
Implement compression for inline methods.
* net/tramp.el (tramp-inline-compress-start-size): New defcustom.
(tramp-copy-size-limit): Allow also nil.
(tramp-inline-compress-commands): New defconst.
(tramp-find-inline-compress, tramp-get-inline-compress)
(tramp-get-inline-coding): New defuns.
(tramp-get-remote-coding, tramp-get-local-coding): Remove,
replaced by `tramp-get-inline-coding'.
(tramp-handle-file-local-copy, tramp-handle-write-region)
(tramp-method-out-of-band-p): Use `tramp-get-inline-coding'.
2010-08-26 Noah Lavine <noah549@gmail.com> (tiny change)
Detect ssh 'ControlMaster' argument automatically in some cases.
* net/tramp.el (tramp-detect-ssh-controlmaster): New defun.
(tramp-default-method): Use it.
2010-08-26 Karel Klíč <kklic@redhat.com>
* net/tramp.el (tramp-file-name-for-operation):
Add file-selinux-context.
2010-08-26 Łukasz Stelmach <lukasz.stelmach@iem.pw.edu.pl> (tiny change)
* play/cookie1.el (read-cookie): Fix off-by-one error (bug#6921).
......
......@@ -106,8 +106,7 @@ This includes password cache, file cache, connection cache, buffers."
(setq tramp-locked nil)
;; Flush password cache.
(when (functionp 'password-reset)
(funcall (symbol-function 'password-reset)))
(tramp-compat-funcall 'password-reset)
;; Flush file and connection cache.
(clrhash tramp-cache-data)
......@@ -226,7 +225,7 @@ Before reproducing the bug, you might apply
This allows to investigate from a clean environment. Another
useful thing to do is to put
(setq tramp-verbose 8)
(setq tramp-verbose 9)
in the ~/.emacs file and to repeat the bug. Then, include the
contents of the *tramp/foo* buffer and the *debug tramp/foo*
......@@ -254,7 +253,7 @@ Used for non-7bit chars in strings."
(base64-encode-string val))))))
;; Dump variable.
(funcall (symbol-function 'reporter-dump-variable) varsym mailbuf)
(tramp-compat-funcall 'reporter-dump-variable varsym mailbuf)
(unless (hash-table-p val)
;; Remove string quotation.
......@@ -283,10 +282,8 @@ Used for non-7bit chars in strings."
(load "mml" 'noerror))
(require 'message nil 'noerror)
(require 'mml nil 'noerror))
(when (functionp 'message-mode)
(funcall (symbol-function 'message-mode)))
(when (functionp 'mml-mode)
(funcall (symbol-function 'mml-mode) t)))
(tramp-compat-funcall 'message-mode)
(tramp-compat-funcall 'mml-mode t))
(defun tramp-append-tramp-buffers ()
"Append Tramp buffers and buffer local variables into the bug report."
......@@ -308,15 +305,14 @@ Used for non-7bit chars in strings."
(erase-buffer)
(insert "\n(setq\n")
(lisp-indent-line)
(funcall (symbol-function 'reporter-dump-variable)
'buffer-name (current-buffer))
(tramp-compat-funcall
'reporter-dump-variable 'buffer-name (current-buffer))
(dolist (varsym-or-cons-cell (buffer-local-variables buffer))
(let ((varsym (or (car-safe varsym-or-cons-cell)
varsym-or-cons-cell)))
(when (string-match "tramp" (symbol-name varsym))
(funcall
(symbol-function 'reporter-dump-variable)
varsym (current-buffer)))))
(tramp-compat-funcall
'reporter-dump-variable varsym (current-buffer)))))
(lisp-indent-line)
(insert ")\n"))
(insert-buffer-substring elbuf)))
......@@ -328,7 +324,7 @@ Used for non-7bit chars in strings."
(symbol-value 'mml-mode))
(let ((tramp-buf-regexp "\\*\\(debug \\)?tramp/")
(buffer-list (funcall (symbol-function 'tramp-list-tramp-buffers)))
(buffer-list (tramp-compat-funcall 'tramp-list-tramp-buffers))
(curbuf (current-buffer)))
;; There is at least one Tramp buffer.
......@@ -376,10 +372,10 @@ This is a special notion of the `gnus/message' package. If you
use another mail agent (by copying the contents of this buffer)
please ensure that the buffers are attached to your email.\n\n")
(dolist (buffer buffer-list)
(funcall (symbol-function 'mml-insert-empty-tag)
'part 'type "text/plain" 'encoding "base64"
'disposition "attachment" 'buffer buffer
'description buffer))
(tramp-compat-funcall
'mml-insert-empty-tag 'part 'type "text/plain"
'encoding "base64" 'disposition "attachment" 'buffer buffer
'description buffer))
(set-buffer-modified-p nil))
;; Don't send. Delete the message buffer.
......
......@@ -22,9 +22,9 @@
;;; Commentary:
;; Tramp's main Emacs version for development is GNU Emacs 23. This
;; package provides compatibility functions for GNU Emacs 21, GNU
;; Emacs 22 and XEmacs 21.4+.
;; Tramp's main Emacs version for development is GNU Emacs 24. This
;; package provides compatibility functions for GNU Emacs 22, GNU
;; Emacs 23 and XEmacs 21.4+.
;;; Code:
......@@ -44,33 +44,31 @@
(autoload 'tramp-tramp-file-p "tramp")
(autoload 'tramp-file-name-handler "tramp")
(autoload 'tramp-handle-file-remote-p "tramp")
;; tramp-util offers integration into other (X)Emacs packages like
;; compile.el, gud.el etc. Not necessary in Emacs 23.
(eval-after-load "tramp"
;; We check whether `start-file-process' is an alias.
'(when (or (not (fboundp 'start-file-process))
(symbolp (symbol-function 'start-file-process)))
(require 'tramp-util)
(add-hook 'tramp-unload-hook
'(lambda ()
(when (featurep 'tramp-util)
(unload-feature 'tramp-util 'force))))))
;; Make sure that we get integration with the VC package. When it
;; is loaded, we need to pull in the integration module. Not
;; necessary in Emacs 23.
(eval-after-load "vc"
;; We check whether `start-file-process' is bound.
(unless (fboundp 'start-file-process)
;; tramp-util offers integration into other (X)Emacs packages like
;; compile.el, gud.el etc. Not necessary in Emacs 23.
(eval-after-load "tramp"
;; We check whether `start-file-process' is an alias.
'(when (or (not (fboundp 'start-file-process))
(symbolp (symbol-function 'start-file-process)))
(require 'tramp-vc)
'(progn
(require 'tramp-util)
(add-hook 'tramp-unload-hook
'(lambda ()
(when (featurep 'tramp-vc)
(unload-feature 'tramp-vc 'force)))))))
(when (featurep 'tramp-util)
(unload-feature 'tramp-util 'force))))))
;; Make sure that we get integration with the VC package. When it
;; is loaded, we need to pull in the integration module. Not
;; necessary in Emacs 23.
(eval-after-load "vc"
(eval-after-load "tramp"
'(progn
(require 'tramp-vc)
(add-hook 'tramp-unload-hook
'(lambda ()
(when (featurep 'tramp-vc)
(unload-feature 'tramp-vc 'force))))))))
;; Avoid byte-compiler warnings if the byte-compiler supports this.
;; Currently, XEmacs supports this.
......@@ -89,14 +87,25 @@
(unless (boundp 'byte-compile-not-obsolete-var)
(defvar byte-compile-not-obsolete-var nil))
(setq byte-compile-not-obsolete-var 'directory-sep-char)
(if (boundp 'byte-compile-not-obsolete-vars) ; Emacs 23.2
(setq byte-compile-not-obsolete-vars '(directory-sep-char)))
;; Emacs 23.2.
(unless (boundp 'byte-compile-not-obsolete-vars)
(defvar byte-compile-not-obsolete-vars nil))
(setq byte-compile-not-obsolete-vars '(directory-sep-char))
;; `with-temp-message' does not exists in XEmacs.
(condition-case nil
(with-temp-message (current-message) nil)
(error (defmacro with-temp-message (message &rest body) `(progn ,@body))))
;; For not existing functions, or functions with a changed argument
;; list, there are compiler warnings. We want to avoid them in
;; cases we know what we do.
(defmacro tramp-compat-funcall (function &rest arguments)
(if (featurep 'xemacs)
`(funcall (symbol-function ,function) ,@arguments)
`(when (or (subrp ,function) (functionp ,function))
(with-no-warnings (funcall ,function ,@arguments)))))
;; `set-buffer-multibyte' comes from Emacs Leim.
(unless (fboundp 'set-buffer-multibyte)
(defalias 'set-buffer-multibyte 'ignore))
......@@ -120,7 +129,7 @@
(tramp-file-name-handler
'file-remote-p file identification connected)))))
;; `process-file' exists since Emacs 22.
;; `process-file' does not exist in XEmacs.
(unless (fboundp 'process-file)
(defalias 'process-file
(lambda (program &optional infile buffer display &rest args)
......@@ -154,7 +163,9 @@
;; return the original filename if it can't expand anything. Let's
;; just hope that this doesn't break anything else.
;; It is not needed anymore since GNU Emacs 23.2.
(unless (or (featurep 'xemacs) (featurep 'files 'remote-wildcards))
(unless (or (featurep 'xemacs)
;; `featurep' has only one argument in XEmacs.
(funcall 'featurep 'files 'remote-wildcards))
(defadvice file-expand-wildcards
(around tramp-advice-file-expand-wildcards activate)
(let ((name (ad-get-arg 0)))
......@@ -163,7 +174,8 @@
(if (and
(tramp-tramp-file-p name)
(not (string-match
"[[*?]" (tramp-handle-file-remote-p name 'localname))))
"[[*?]" (tramp-compat-funcall
'file-remote-p name 'localname))))
(setq ad-return-value (list name))
;; Otherwise, just run the original function.
ad-do-it)))
......@@ -180,8 +192,8 @@ Calls `line-beginning-position' or `point-at-bol' if defined, else
own implementation."
(cond
((fboundp 'line-beginning-position)
(funcall (symbol-function 'line-beginning-position)))
((fboundp 'point-at-bol) (funcall (symbol-function 'point-at-bol)))
(tramp-compat-funcall 'line-beginning-position))
((fboundp 'point-at-bol) (tramp-compat-funcall 'point-at-bol))
(t (save-excursion (beginning-of-line) (point)))))
(defsubst tramp-compat-line-end-position ()
......@@ -189,8 +201,8 @@ own implementation."
Calls `line-end-position' or `point-at-eol' if defined, else
own implementation."
(cond
((fboundp 'line-end-position) (funcall (symbol-function 'line-end-position)))
((fboundp 'point-at-eol) (funcall (symbol-function 'point-at-eol)))
((fboundp 'line-end-position) (tramp-compat-funcall 'line-end-position))
((fboundp 'point-at-eol) (tramp-compat-funcall 'point-at-eol))
(t (save-excursion (end-of-line) (point)))))
(defsubst tramp-compat-temporary-file-directory ()
......@@ -199,7 +211,7 @@ For Emacs, this is the variable `temporary-file-directory', for XEmacs
this is the function `temp-directory'."
(cond
((boundp 'temporary-file-directory) (symbol-value 'temporary-file-directory))
((fboundp 'temp-directory) (funcall (symbol-function 'temp-directory)))
((fboundp 'temp-directory) (tramp-compat-funcall 'temp-directory))
((let ((d (getenv "TEMP"))) (and d (file-directory-p d)))
(file-name-as-directory (getenv "TEMP")))
((let ((d (getenv "TMP"))) (and d (file-directory-p d)))
......@@ -211,10 +223,9 @@ this is the function `temp-directory'."
"`temp-directory' is defined -- using /tmp."))
(file-name-as-directory "/tmp"))))
;; `make-temp-file' exists in Emacs only. The third parameter SUFFIX
;; has been introduced with Emacs 22. We try it, if it fails, we fall
;; back to `make-temp-name', creating the temporary file immediately
;; in order to avoid a security hole.
;; `make-temp-file' exists in Emacs only. On XEmacs, we use our own
;; implementation with `make-temp-name', creating the temporary file
;; immediately in order to avoid a security hole.
(defsubst tramp-compat-make-temp-file (filename &optional dir-flag)
"Create a temporary file (compat function).
Add the extension of FILENAME, if existing."
......@@ -226,8 +237,7 @@ Add the extension of FILENAME, if existing."
result)
(condition-case nil
(setq result
(funcall
(symbol-function 'make-temp-file) prefix dir-flag extension))
(tramp-compat-funcall 'make-temp-file prefix dir-flag extension))
(error
;; We use our own implementation, taken from files.el.
(while
......@@ -236,14 +246,7 @@ Add the extension of FILENAME, if existing."
(setq result (concat (make-temp-name prefix) extension))
(if dir-flag
(make-directory result)
(write-region
"" nil result nil 'silent nil
;; 7th parameter is MUSTBENEW in Emacs, and
;; CODING-SYSTEM in XEmacs. It is not a security
;; hole in XEmacs if we cannot use this parameter,
;; because XEmacs uses a user-specific
;; subdirectory with 0700 permissions.
(when (not (featurep 'xemacs)) 'excl)))
(write-region "" nil result nil 'silent))
nil)
(file-already-exists t))
;; The file was somehow created by someone else between
......@@ -251,16 +254,15 @@ Add the extension of FILENAME, if existing."
nil)))
result))
;; `most-positive-fixnum' arrived in Emacs 22. Before, and in XEmacs,
;; it is a fixed value.
;; `most-positive-fixnum' does not exist in XEmacs.
(defsubst tramp-compat-most-positive-fixnum ()
"Return largest positive integer value (compat function)."
(cond
((boundp 'most-positive-fixnum) (symbol-value 'most-positive-fixnum))
;; Default value in XEmacs and Emacs 21.
;; Default value in XEmacs.
(t 134217727)))
;; ID-FORMAT exists since Emacs 22.
;; ID-FORMAT does not exists in XEmacs.
(defun tramp-compat-file-attributes (filename &optional id-format)
"Like `file-attributes' for Tramp files (compat function)."
(cond
......@@ -269,19 +271,27 @@ Add the extension of FILENAME, if existing."
((tramp-tramp-file-p filename)
(tramp-file-name-handler 'file-attributes filename id-format))
(t (condition-case nil
(funcall (symbol-function 'file-attributes) filename id-format)
(error (file-attributes filename))))))
(tramp-compat-funcall 'file-attributes filename id-format)
(wrong-number-of-arguments (file-attributes filename))))))
;; PRESERVE-UID-GID has been introduced with Emacs 23. It does not
;; hurt to ignore it for other (X)Emacs versions.
;; PRESERVE-SELINUX-CONTEXT has been introduced with Emacs 24.
(defun tramp-compat-copy-file
(filename newname &optional ok-if-already-exists keep-date preserve-uid-gid)
(filename newname &optional ok-if-already-exists keep-date
preserve-uid-gid preserve-selinux-context)
"Like `copy-file' for Tramp files (compat function)."
(if preserve-uid-gid
(funcall
(symbol-function 'copy-file)
filename newname ok-if-already-exists keep-date preserve-uid-gid)
(copy-file filename newname ok-if-already-exists keep-date)))
(cond
(preserve-selinux-context
(tramp-compat-funcall
'copy-file filename newname ok-if-already-exists keep-date
preserve-uid-gid preserve-selinux-context))
(preserve-uid-gid
(tramp-compat-funcall
'copy-file filename newname ok-if-already-exists keep-date
preserve-uid-gid))
(t
(copy-file filename newname ok-if-already-exists keep-date))))
;; `copy-directory' is a new function in Emacs 23.2. Implementation
;; is taken from there.
......@@ -289,11 +299,10 @@ Add the extension of FILENAME, if existing."
(directory newname &optional keep-time parents)
"Make a copy of DIRECTORY (compat function)."
(if (fboundp 'copy-directory)
(funcall
(symbol-function 'copy-directory) directory newname keep-time parents)
(tramp-compat-funcall 'copy-directory directory newname keep-time parents)
;; If default-directory is a remote directory, make sure we find
;; its copy-directory handler.
;; If `default-directory' is a remote directory, make sure we find
;; its `copy-directory' handler.
(let ((handler (or (find-file-name-handler directory 'copy-directory)
(find-file-name-handler newname 'copy-directory))))
(if handler
......@@ -325,36 +334,45 @@ Add the extension of FILENAME, if existing."
(if keep-time
(set-file-times newname (nth 5 (file-attributes directory))))))))
;; `copy-tree' is a built-in function in XEmacs. In Emacs 21, it is
;; an autoloaded function in cl-extra.el. Since Emacs 22, it is part
;; of subr.el. There are problems when autoloading, therefore we test
;; for `subrp' and `symbol-file'. Implementation is taken from Emacs 23.
(defun tramp-compat-copy-tree (tree)
"Make a copy of TREE (compat function)."
(if (or (subrp 'copy-tree) (symbol-file 'copy-tree))
(funcall (symbol-function 'copy-tree) tree)
(let (result)
(while (consp tree)
(let ((newcar (car tree)))
(if (consp (car tree))
(setq newcar (tramp-compat-copy-tree (car tree))))
(push newcar result))
(setq tree (cdr tree)))
(nconc (nreverse result) tree))))
;; TRASH has been introduced with Emacs 24.1.
(defun tramp-compat-delete-file (filename &optional trash)
"Like `delete-file' for Tramp files (compat function)."
(condition-case nil
(tramp-compat-funcall 'delete-file filename trash)
;; This Emacs version does not support the TRASH flag.
(wrong-number-of-arguments
(let ((delete-by-moving-to-trash
(and (boundp 'delete-by-moving-to-trash)