diff options
| author | Michael Albinus | 2010-05-01 11:34:14 +0200 |
|---|---|---|
| committer | Michael Albinus | 2010-05-01 11:34:14 +0200 |
| commit | 6a29a838dd404e62820ededdc6b1b9bb04101d46 (patch) | |
| tree | d051fa7d7a52a43f6f13563ff9dc9e001ca1f8e3 | |
| parent | 7acac9f4ce1b49c8d953b80b83c4ecd7dd919676 (diff) | |
| download | emacs-6a29a838dd404e62820ededdc6b1b9bb04101d46.tar.gz emacs-6a29a838dd404e62820ededdc6b1b9bb04101d46.zip | |
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): Removed,
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'.
| -rw-r--r-- | lisp/ChangeLog | 15 | ||||
| -rw-r--r-- | lisp/net/tramp.el | 420 |
2 files changed, 284 insertions, 151 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7cac121af0c..170d22a106b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | 2010-05-01 Toru TSUNEYOSHI <t_tuneyosi@hotmail.com> | ||
| 2 | Michael Albinus <michael.albinus@gmx.de> | ||
| 3 | |||
| 4 | Implement compression for inline methods. | ||
| 5 | |||
| 6 | * net/tramp.el (tramp-inline-compress-start-size): New defcustom. | ||
| 7 | (tramp-copy-size-limit): Allow also nil. | ||
| 8 | (tramp-inline-compress-commands): New defconst. | ||
| 9 | (tramp-find-inline-compress, tramp-get-inline-compress) | ||
| 10 | (tramp-get-inline-coding): New defuns. | ||
| 11 | (tramp-get-remote-coding, tramp-get-local-coding): Removed, | ||
| 12 | replaced by `tramp-get-inline-coding'. | ||
| 13 | (tramp-handle-file-local-copy, tramp-handle-write-region) | ||
| 14 | (tramp-method-out-of-band-p): Use `tramp-get-inline-coding'. | ||
| 15 | |||
| 1 | 2010-05-01 Chong Yidong <cyd@stupidchicken.com> | 16 | 2010-05-01 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 17 | ||
| 3 | * server.el (server-sentinel, server-start, server-force-delete): | 18 | * server.el (server-sentinel, server-start, server-force-delete): |
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index f82ecddc3c4..a385efa2c01 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -285,10 +285,19 @@ See the variable `tramp-encoding-shell' for more information." | |||
| 285 | :group 'tramp | 285 | :group 'tramp |
| 286 | :type 'string) | 286 | :type 'string) |
| 287 | 287 | ||
| 288 | (defcustom tramp-inline-compress-start-size 4096 | ||
| 289 | "*The minimum size of compressing where inline transfer. | ||
| 290 | When inline transfer, compress transfered data of file | ||
| 291 | whose size is this value or above (up to `tramp-copy-size-limit'). | ||
| 292 | If it is nil, no compression at all will be applied." | ||
| 293 | :group 'tramp | ||
| 294 | :type '(choice (const nil) integer)) | ||
| 295 | |||
| 288 | (defcustom tramp-copy-size-limit 10240 | 296 | (defcustom tramp-copy-size-limit 10240 |
| 289 | "*The maximum file size where inline copying is preferred over an out-of-the-band copy." | 297 | "*The maximum file size where inline copying is preferred over an out-of-the-band copy. |
| 298 | If it is nil, inline out-of-the-band copy will be used without a check." | ||
| 290 | :group 'tramp | 299 | :group 'tramp |
| 291 | :type 'integer) | 300 | :type '(choice (const nil) integer)) |
| 292 | 301 | ||
| 293 | (defcustom tramp-terminal-type "dumb" | 302 | (defcustom tramp-terminal-type "dumb" |
| 294 | "*Value of TERM environment variable for logging in to remote host. | 303 | "*Value of TERM environment variable for logging in to remote host. |
| @@ -4722,16 +4731,16 @@ Lisp error raised when PROGRAM is nil is trapped also, returning 1." | |||
| 4722 | v 'file-error | 4731 | v 'file-error |
| 4723 | "Cannot make local copy of non-existing file `%s'" filename)) | 4732 | "Cannot make local copy of non-existing file `%s'" filename)) |
| 4724 | 4733 | ||
| 4725 | (let ((rem-enc (tramp-get-remote-coding v "remote-encoding")) | 4734 | (let* ((size (nth 7 (file-attributes filename))) |
| 4726 | (loc-dec (tramp-get-local-coding v "local-decoding")) | 4735 | (rem-enc (tramp-get-inline-coding v "remote-encoding" size)) |
| 4727 | (tmpfile (tramp-compat-make-temp-file filename))) | 4736 | (loc-dec (tramp-get-inline-coding v "local-decoding" size)) |
| 4737 | (tmpfile (tramp-compat-make-temp-file filename))) | ||
| 4728 | 4738 | ||
| 4729 | (condition-case err | 4739 | (condition-case err |
| 4730 | (cond | 4740 | (cond |
| 4731 | ;; `copy-file' handles direct copy and out-of-band methods. | 4741 | ;; `copy-file' handles direct copy and out-of-band methods. |
| 4732 | ((or (tramp-local-host-p v) | 4742 | ((or (tramp-local-host-p v) |
| 4733 | (tramp-method-out-of-band-p | 4743 | (tramp-method-out-of-band-p v size)) |
| 4734 | v (nth 7 (file-attributes filename)))) | ||
| 4735 | (copy-file filename tmpfile t t)) | 4744 | (copy-file filename tmpfile t t)) |
| 4736 | 4745 | ||
| 4737 | ;; Use inline encoding for file transfer. | 4746 | ;; Use inline encoding for file transfer. |
| @@ -4739,12 +4748,11 @@ Lisp error raised when PROGRAM is nil is trapped also, returning 1." | |||
| 4739 | (save-excursion | 4748 | (save-excursion |
| 4740 | (tramp-message v 5 "Encoding remote file %s..." filename) | 4749 | (tramp-message v 5 "Encoding remote file %s..." filename) |
| 4741 | (tramp-barf-unless-okay | 4750 | (tramp-barf-unless-okay |
| 4742 | v | 4751 | v (format rem-enc (tramp-shell-quote-argument localname)) |
| 4743 | (format "%s < %s" rem-enc (tramp-shell-quote-argument localname)) | ||
| 4744 | "Encoding remote file failed") | 4752 | "Encoding remote file failed") |
| 4745 | (tramp-message v 5 "Encoding remote file %s...done" filename) | 4753 | (tramp-message v 5 "Encoding remote file %s...done" filename) |
| 4746 | 4754 | ||
| 4747 | (if (and (symbolp loc-dec) (fboundp loc-dec)) | 4755 | (if (functionp loc-dec) |
| 4748 | ;; If local decoding is a function, we call it. We | 4756 | ;; If local decoding is a function, we call it. We |
| 4749 | ;; must disable multibyte, because | 4757 | ;; must disable multibyte, because |
| 4750 | ;; `uudecode-decode-region' doesn't handle it | 4758 | ;; `uudecode-decode-region' doesn't handle it |
| @@ -5093,12 +5101,10 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file." | |||
| 5093 | 'write-region | 5101 | 'write-region |
| 5094 | (list start end localname append 'no-message lockname confirm)) | 5102 | (list start end localname append 'no-message lockname confirm)) |
| 5095 | 5103 | ||
| 5096 | (let ((rem-dec (tramp-get-remote-coding v "remote-decoding")) | 5104 | (let ((modes (save-excursion (tramp-default-file-modes filename))) |
| 5097 | (loc-enc (tramp-get-local-coding v "local-encoding")) | ||
| 5098 | (modes (save-excursion (tramp-default-file-modes filename))) | ||
| 5099 | ;; We use this to save the value of | 5105 | ;; We use this to save the value of |
| 5100 | ;; `last-coding-system-used' after writing the tmp file. | 5106 | ;; `last-coding-system-used' after writing the tmp |
| 5101 | ;; At the end of the function, we set | 5107 | ;; file. At the end of the function, we set |
| 5102 | ;; `last-coding-system-used' to this saved value. This | 5108 | ;; `last-coding-system-used' to this saved value. This |
| 5103 | ;; way, any intermediary coding systems used while | 5109 | ;; way, any intermediary coding systems used while |
| 5104 | ;; talking to the remote shell or suchlike won't hose | 5110 | ;; talking to the remote shell or suchlike won't hose |
| @@ -5121,7 +5127,8 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file." | |||
| 5121 | ;; file. We call `set-visited-file-modtime' ourselves later | 5127 | ;; file. We call `set-visited-file-modtime' ourselves later |
| 5122 | ;; on. We must ensure that `file-coding-system-alist' | 5128 | ;; on. We must ensure that `file-coding-system-alist' |
| 5123 | ;; matches `tmpfile'. | 5129 | ;; matches `tmpfile'. |
| 5124 | (let ((file-coding-system-alist | 5130 | (let (file-name-handler-alist |
| 5131 | (file-coding-system-alist | ||
| 5125 | (tramp-find-file-name-coding-system-alist filename tmpfile))) | 5132 | (tramp-find-file-name-coding-system-alist filename tmpfile))) |
| 5126 | (condition-case err | 5133 | (condition-case err |
| 5127 | (tramp-run-real-handler | 5134 | (tramp-run-real-handler |
| @@ -5153,124 +5160,125 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file." | |||
| 5153 | ;; specified. However, if the method _also_ specifies an | 5160 | ;; specified. However, if the method _also_ specifies an |
| 5154 | ;; encoding function, then that is used for encoding the | 5161 | ;; encoding function, then that is used for encoding the |
| 5155 | ;; contents of the tmp file. | 5162 | ;; contents of the tmp file. |
| 5156 | (cond | 5163 | (let* ((size (nth 7 (file-attributes tmpfile))) |
| 5157 | ;; `copy-file' handles direct copy and out-of-band methods. | 5164 | (rem-dec (tramp-get-inline-coding v "remote-decoding" size)) |
| 5158 | ((or (tramp-local-host-p v) | 5165 | (loc-enc (tramp-get-inline-coding v "local-encoding" size))) |
| 5159 | (tramp-method-out-of-band-p | 5166 | (cond |
| 5160 | v (nth 7 (file-attributes tmpfile)))) | 5167 | ;; `copy-file' handles direct copy and out-of-band methods. |
| 5161 | (if (and (not (stringp start)) | 5168 | ((or (tramp-local-host-p v) |
| 5162 | (= (or end (point-max)) (point-max)) | 5169 | (tramp-method-out-of-band-p v size)) |
| 5163 | (= (or start (point-min)) (point-min)) | 5170 | (if (and (not (stringp start)) |
| 5164 | (tramp-get-method-parameter | 5171 | (= (or end (point-max)) (point-max)) |
| 5165 | method 'tramp-copy-keep-tmpfile)) | 5172 | (= (or start (point-min)) (point-min)) |
| 5166 | (progn | 5173 | (tramp-get-method-parameter |
| 5167 | (setq tramp-temp-buffer-file-name tmpfile) | 5174 | method 'tramp-copy-keep-tmpfile)) |
| 5168 | (condition-case err | 5175 | (progn |
| 5169 | ;; We keep the local file for performance | 5176 | (setq tramp-temp-buffer-file-name tmpfile) |
| 5170 | ;; reasons, useful for "rsync". | 5177 | (condition-case err |
| 5171 | (copy-file tmpfile filename t) | 5178 | ;; We keep the local file for performance |
| 5172 | ((error quit) | 5179 | ;; reasons, useful for "rsync". |
| 5173 | (setq tramp-temp-buffer-file-name nil) | 5180 | (copy-file tmpfile filename t) |
| 5174 | (delete-file tmpfile) | 5181 | ((error quit) |
| 5175 | (signal (car err) (cdr err))))) | 5182 | (setq tramp-temp-buffer-file-name nil) |
| 5176 | (setq tramp-temp-buffer-file-name nil) | 5183 | (delete-file tmpfile) |
| 5177 | ;; Don't rename, in order to keep context in SELinux. | 5184 | (signal (car err) (cdr err))))) |
| 5185 | (setq tramp-temp-buffer-file-name nil) | ||
| 5186 | ;; Don't rename, in order to keep context in SELinux. | ||
| 5187 | (unwind-protect | ||
| 5188 | (copy-file tmpfile filename t) | ||
| 5189 | (delete-file tmpfile)))) | ||
| 5190 | |||
| 5191 | ;; Use inline file transfer. | ||
| 5192 | (rem-dec | ||
| 5193 | ;; Encode tmpfile. | ||
| 5194 | (tramp-message v 5 "Encoding region...") | ||
| 5178 | (unwind-protect | 5195 | (unwind-protect |
| 5179 | (copy-file tmpfile filename t) | 5196 | (with-temp-buffer |
| 5180 | (delete-file tmpfile)))) | 5197 | (set-buffer-multibyte nil) |
| 5181 | 5198 | ;; Use encoding function or command. | |
| 5182 | ;; Use inline file transfer. | 5199 | (if (functionp loc-enc) |
| 5183 | (rem-dec | 5200 | (progn |
| 5184 | ;; Encode tmpfile. | 5201 | (tramp-message |
| 5185 | (tramp-message v 5 "Encoding region...") | 5202 | v 5 "Encoding region using function `%s'..." loc-enc) |
| 5186 | (unwind-protect | 5203 | (let ((coding-system-for-read 'binary)) |
| 5187 | (with-temp-buffer | 5204 | (insert-file-contents-literally tmpfile)) |
| 5188 | ;; Use encoding function or command. | 5205 | ;; The following `let' is a workaround for the |
| 5189 | (if (and (symbolp loc-enc) (fboundp loc-enc)) | 5206 | ;; base64.el that comes with pgnus-0.84. If |
| 5190 | (progn | 5207 | ;; both of the following conditions are |
| 5191 | (tramp-message | 5208 | ;; satisfied, it tries to write to a local |
| 5192 | v 5 "Encoding region using function `%s'..." | 5209 | ;; file in default-directory, but at this |
| 5193 | (symbol-name loc-enc)) | 5210 | ;; point, default-directory is remote. |
| 5194 | (let ((coding-system-for-read 'binary)) | 5211 | ;; (`call-process-region' can't write to |
| 5195 | (insert-file-contents-literally tmpfile)) | 5212 | ;; remote files, it seems.) The file in |
| 5196 | ;; The following `let' is a workaround for the | 5213 | ;; question is a tmp file anyway. |
| 5197 | ;; base64.el that comes with pgnus-0.84. If | 5214 | (let ((default-directory |
| 5198 | ;; both of the following conditions are | 5215 | (tramp-compat-temporary-file-directory))) |
| 5199 | ;; satisfied, it tries to write to a local | 5216 | (funcall loc-enc (point-min) (point-max)))) |
| 5200 | ;; file in default-directory, but at this | 5217 | |
| 5201 | ;; point, default-directory is remote. | 5218 | (tramp-message |
| 5202 | ;; (`call-process-region' can't write to | 5219 | v 5 "Encoding region using command `%s'..." loc-enc) |
| 5203 | ;; remote files, it seems.) The file in | 5220 | (unless (zerop (tramp-call-local-coding-command |
| 5204 | ;; question is a tmp file anyway. | ||
| 5205 | (let ((default-directory | ||
| 5206 | (tramp-compat-temporary-file-directory))) | ||
| 5207 | (funcall loc-enc (point-min) (point-max)))) | ||
| 5208 | |||
| 5209 | (tramp-message | ||
| 5210 | v 5 "Encoding region using command `%s'..." loc-enc) | ||
| 5211 | (unless (equal 0 (tramp-call-local-coding-command | ||
| 5212 | loc-enc tmpfile t)) | 5221 | loc-enc tmpfile t)) |
| 5213 | (tramp-error | 5222 | (tramp-error |
| 5214 | v 'file-error | 5223 | v 'file-error |
| 5215 | "Cannot write to `%s', local encoding command `%s' failed" | 5224 | "Cannot write to `%s', local encoding command `%s' failed" |
| 5216 | filename loc-enc))) | 5225 | filename loc-enc))) |
| 5217 | 5226 | ||
| 5218 | ;; Send buffer into remote decoding command which | 5227 | ;; Send buffer into remote decoding command which |
| 5219 | ;; writes to remote file. Because this happens on | 5228 | ;; writes to remote file. Because this happens on |
| 5220 | ;; the remote host, we cannot use the function. | 5229 | ;; the remote host, we cannot use the function. |
| 5221 | (goto-char (point-max)) | 5230 | (goto-char (point-max)) |
| 5222 | (unless (bolp) (newline)) | 5231 | (unless (bolp) (newline)) |
| 5223 | (tramp-message | 5232 | (tramp-message |
| 5224 | v 5 "Decoding region into remote file %s..." filename) | 5233 | v 5 "Decoding region into remote file %s..." filename) |
| 5225 | (tramp-send-command | 5234 | (tramp-send-command |
| 5226 | v | 5235 | v |
| 5227 | (format | 5236 | (format |
| 5228 | "%s >%s <<'EOF'\n%sEOF" | 5237 | (concat rem-dec " <<'EOF'\n%sEOF") |
| 5229 | rem-dec | 5238 | (tramp-shell-quote-argument localname) |
| 5230 | (tramp-shell-quote-argument localname) | 5239 | (buffer-string))) |
| 5231 | (buffer-string))) | 5240 | (tramp-barf-unless-okay |
| 5232 | (tramp-barf-unless-okay | 5241 | v nil |
| 5233 | v nil | 5242 | "Couldn't write region to `%s', decode using `%s' failed" |
| 5234 | "Couldn't write region to `%s', decode using `%s' failed" | 5243 | filename rem-dec) |
| 5235 | filename rem-dec) | 5244 | ;; When `file-precious-flag' is set, the region is |
| 5236 | ;; When `file-precious-flag' is set, the region is | 5245 | ;; written to a temporary file. Check that the |
| 5237 | ;; written to a temporary file. Check that the | 5246 | ;; checksum is equal to that from the local tmpfile. |
| 5238 | ;; checksum is equal to that from the local tmpfile. | 5247 | (when file-precious-flag |
| 5239 | (when file-precious-flag | 5248 | (erase-buffer) |
| 5240 | (erase-buffer) | 5249 | (and |
| 5241 | (and | 5250 | ;; cksum runs locally, if possible. |
| 5242 | ;; cksum runs locally, if possible. | 5251 | (zerop (tramp-local-call-process "cksum" tmpfile t)) |
| 5243 | (zerop (tramp-local-call-process "cksum" tmpfile t)) | 5252 | ;; cksum runs remotely. |
| 5244 | ;; cksum runs remotely. | 5253 | (zerop |
| 5245 | (zerop | 5254 | (tramp-send-command-and-check |
| 5246 | (tramp-send-command-and-check | 5255 | v |
| 5247 | v | 5256 | (format |
| 5248 | (format | 5257 | "cksum <%s" (tramp-shell-quote-argument localname)))) |
| 5249 | "cksum <%s" (tramp-shell-quote-argument localname)))) | 5258 | ;; ... they are different. |
| 5250 | ;; ... they are different. | 5259 | (not |
| 5251 | (not | 5260 | (string-equal |
| 5252 | (string-equal | 5261 | (buffer-string) |
| 5253 | (buffer-string) | 5262 | (with-current-buffer (tramp-get-buffer v) |
| 5254 | (with-current-buffer (tramp-get-buffer v) | 5263 | (buffer-string)))) |
| 5255 | (buffer-string)))) | 5264 | (tramp-error |
| 5256 | (tramp-error | 5265 | v 'file-error |
| 5257 | v 'file-error | 5266 | (concat "Couldn't write region to `%s'," |
| 5258 | (concat "Couldn't write region to `%s'," | 5267 | " decode using `%s' failed") |
| 5259 | " decode using `%s' failed") | 5268 | filename rem-dec))) |
| 5260 | filename rem-dec))) | 5269 | (tramp-message |
| 5261 | (tramp-message | 5270 | v 5 "Decoding region into remote file %s...done" filename)) |
| 5262 | v 5 "Decoding region into remote file %s...done" filename)) | ||
| 5263 | 5271 | ||
| 5264 | ;; Save exit. | 5272 | ;; Save exit. |
| 5265 | (delete-file tmpfile))) | 5273 | (delete-file tmpfile))) |
| 5266 | 5274 | ||
| 5267 | ;; That's not expected. | 5275 | ;; That's not expected. |
| 5268 | (t | 5276 | (t |
| 5269 | (tramp-error | 5277 | (tramp-error |
| 5270 | v 'file-error | 5278 | v 'file-error |
| 5271 | (concat "Method `%s' should specify both encoding and " | 5279 | (concat "Method `%s' should specify both encoding and " |
| 5272 | "decoding command or an rcp program") | 5280 | "decoding command or an rcp program") |
| 5273 | method))) | 5281 | method)))) |
| 5274 | 5282 | ||
| 5275 | ;; Make `last-coding-system-used' have the right value. | 5283 | ;; Make `last-coding-system-used' have the right value. |
| 5276 | (when coding-system-used | 5284 | (when coding-system-used |
| @@ -7200,6 +7208,64 @@ means discard it)." | |||
| 7200 | (if (string-match "%s" cmd) (format cmd input) cmd) | 7208 | (if (string-match "%s" cmd) (format cmd input) cmd) |
| 7201 | (if (stringp output) (concat "> " output) "")))) | 7209 | (if (stringp output) (concat "> " output) "")))) |
| 7202 | 7210 | ||
| 7211 | (defconst tramp-inline-compress-commands | ||
| 7212 | '(("gzip" "gzip -d") | ||
| 7213 | ("bzip2" "bzip2 -d") | ||
| 7214 | ("compress" "compress -d")) | ||
| 7215 | "List of compress and decompress commands for inline transfer. | ||
| 7216 | Each item is a list that looks like this: | ||
| 7217 | |||
| 7218 | \(COMPRESS DECOMPRESS\) | ||
| 7219 | |||
| 7220 | COMPRESS or DECOMPRESS are strings with the respective commands.") | ||
| 7221 | |||
| 7222 | (defun tramp-find-inline-compress (vec) | ||
| 7223 | "Find an inline transfer compress command that works. | ||
| 7224 | Goes through the list `tramp-inline-compress-commands'." | ||
| 7225 | (save-excursion | ||
| 7226 | (let ((commands tramp-inline-compress-commands) | ||
| 7227 | (magic "xyzzy") | ||
| 7228 | item compress decompress | ||
| 7229 | found) | ||
| 7230 | (while (and commands (not found)) | ||
| 7231 | (catch 'next | ||
| 7232 | (setq item (pop commands) | ||
| 7233 | compress (nth 0 item) | ||
| 7234 | decompress (nth 1 item)) | ||
| 7235 | (tramp-message | ||
| 7236 | vec 5 | ||
| 7237 | "Checking local compress command `%s', `%s' for sanity" | ||
| 7238 | compress decompress) | ||
| 7239 | (unless (zerop (tramp-call-local-coding-command | ||
| 7240 | (format "echo %s | %s | %s" | ||
| 7241 | magic compress decompress) nil nil)) | ||
| 7242 | (throw 'next nil)) | ||
| 7243 | (tramp-message | ||
| 7244 | vec 5 | ||
| 7245 | "Checking remote compress command `%s', `%s' for sanity" | ||
| 7246 | compress decompress) | ||
| 7247 | (unless (zerop (tramp-send-command-and-check | ||
| 7248 | vec (format "echo %s | %s | %s" | ||
| 7249 | magic compress decompress) t)) | ||
| 7250 | (throw 'next nil)) | ||
| 7251 | (setq found t))) | ||
| 7252 | |||
| 7253 | ;; Did we find something? | ||
| 7254 | (if found | ||
| 7255 | (progn | ||
| 7256 | ;; Set connection properties. | ||
| 7257 | (tramp-message | ||
| 7258 | vec 5 "Using inline transfer compress command `%s'" compress) | ||
| 7259 | (tramp-set-connection-property vec "inline-compress" compress) | ||
| 7260 | (tramp-message | ||
| 7261 | vec 5 "Using inline transfer decompress command `%s'" decompress) | ||
| 7262 | (tramp-set-connection-property vec "inline-decompress" decompress)) | ||
| 7263 | |||
| 7264 | (tramp-set-connection-property vec "inline-compress" nil) | ||
| 7265 | (tramp-set-connection-property vec "inline-decompress" nil) | ||
| 7266 | (tramp-message | ||
| 7267 | vec 2 "Couldn't find an inline transfer compress command"))))) | ||
| 7268 | |||
| 7203 | (defun tramp-compute-multi-hops (vec) | 7269 | (defun tramp-compute-multi-hops (vec) |
| 7204 | "Expands VEC according to `tramp-default-proxies-alist'. | 7270 | "Expands VEC according to `tramp-default-proxies-alist'. |
| 7205 | Gateway hops are already opened." | 7271 | Gateway hops are already opened." |
| @@ -8079,8 +8145,9 @@ necessary only. This function will be used in file name completion." | |||
| 8079 | (tramp-get-method-parameter (tramp-file-name-method vec) 'tramp-copy-program) | 8145 | (tramp-get-method-parameter (tramp-file-name-method vec) 'tramp-copy-program) |
| 8080 | ;; Either the file size is large enough, or (in rare cases) there | 8146 | ;; Either the file size is large enough, or (in rare cases) there |
| 8081 | ;; does not exist a remote encoding. | 8147 | ;; does not exist a remote encoding. |
| 8082 | (or (> size tramp-copy-size-limit) | 8148 | (or (null tramp-copy-size-limit) |
| 8083 | (null (tramp-get-remote-coding vec "remote-encoding"))))) | 8149 | (> size tramp-copy-size-limit) |
| 8150 | (null (tramp-get-inline-coding vec "remote-encoding" size))))) | ||
| 8084 | 8151 | ||
| 8085 | (defun tramp-local-host-p (vec) | 8152 | (defun tramp-local-host-p (vec) |
| 8086 | "Return t if this points to the local host, nil otherwise." | 8153 | "Return t if this points to the local host, nil otherwise." |
| @@ -8361,31 +8428,82 @@ necessary only. This function will be used in file name completion." | |||
| 8361 | (nth 3 (tramp-compat-file-attributes "~/" id-format))) | 8428 | (nth 3 (tramp-compat-file-attributes "~/" id-format))) |
| 8362 | 8429 | ||
| 8363 | ;; Some predefined connection properties. | 8430 | ;; Some predefined connection properties. |
| 8364 | (defun tramp-get-remote-coding (vec prop) | 8431 | (defun tramp-get-inline-compress (vec prop size) |
| 8365 | ;; Local coding handles properties like remote coding. So we could | 8432 | "Return the compress command related to PROP. |
| 8366 | ;; call it without pain. | 8433 | PROP is either `inline-compress' or `inline-decompress'. SIZE is |
| 8367 | (let ((ret (tramp-get-local-coding vec prop))) | 8434 | the length of the file to be compressed. |
| 8435 | |||
| 8436 | If no corresponding command is found, nil is returned." | ||
| 8437 | (when (and (integerp tramp-inline-compress-start-size) | ||
| 8438 | (> size tramp-inline-compress-start-size)) | ||
| 8439 | (with-connection-property vec prop | ||
| 8440 | (tramp-find-inline-compress vec) | ||
| 8441 | (tramp-get-connection-property vec prop nil)))) | ||
| 8442 | |||
| 8443 | (defun tramp-get-inline-coding (vec prop size) | ||
| 8444 | "Return the coding command related to PROP. | ||
| 8445 | PROP is either `remote-encoding', `remode-decoding', | ||
| 8446 | `local-encoding' or `local-decoding'. | ||
| 8447 | |||
| 8448 | SIZE is the length of the file to be coded. Depending on SIZE, | ||
| 8449 | compression might be applied. | ||
| 8450 | |||
| 8451 | If no corresponding command is found, nil is returned. | ||
| 8452 | Otherwise, either a string is returned which contains a `%s' mark | ||
| 8453 | to be used for the respective input or output file; or a Lisp | ||
| 8454 | function cell is returned to be applied on a buffer." | ||
| 8455 | (let ((coding | ||
| 8456 | (with-connection-property vec prop | ||
| 8457 | (tramp-find-inline-encoding vec) | ||
| 8458 | (tramp-get-connection-property vec prop nil))) | ||
| 8459 | (prop1 (if (string-match "encoding" prop) | ||
| 8460 | "inline-compress" "inline-decompress")) | ||
| 8461 | compress) | ||
| 8368 | ;; The connection property might have been cached. So we must send | 8462 | ;; The connection property might have been cached. So we must send |
| 8369 | ;; the script - maybe. | 8463 | ;; the script to the remote side - maybe. |
| 8370 | (when (and ret (symbolp ret)) | 8464 | (when (and coding (symbolp coding) (string-match "remote" prop)) |
| 8371 | (let ((name (symbol-name ret))) | 8465 | (let ((name (symbol-name coding))) |
| 8372 | (while (string-match (regexp-quote "-") name) | 8466 | (while (string-match (regexp-quote "-") name) |
| 8373 | (setq name (replace-match "_" nil t name))) | 8467 | (setq name (replace-match "_" nil t name))) |
| 8374 | (tramp-maybe-send-script vec (symbol-value ret) name) | 8468 | (tramp-maybe-send-script vec (symbol-value coding) name) |
| 8375 | (setq ret name))) | 8469 | (setq coding name))) |
| 8376 | ;; Return the value. | 8470 | (when coding |
| 8377 | ret)) | 8471 | ;; Check for the `compress' command. |
| 8378 | 8472 | (setq compress (tramp-get-inline-compress vec prop1 size)) | |
| 8379 | (defun tramp-get-local-coding (vec prop) | 8473 | ;; Return the value. |
| 8380 | (or | 8474 | (cond |
| 8381 | (tramp-get-connection-property vec prop nil) | 8475 | ((and compress (symbolp coding)) |
| 8382 | (progn | 8476 | (if (string-match "decompress" prop1) |
| 8383 | (tramp-find-inline-encoding vec) | 8477 | `(lambda (beg end) |
| 8384 | (tramp-get-connection-property vec prop nil)))) | 8478 | (,coding beg end) |
| 8479 | (let ((coding-system-for-write 'binary) | ||
| 8480 | (coding-system-for-read 'binary)) | ||
| 8481 | (apply | ||
| 8482 | 'call-process-region (point-min) (point-max) | ||
| 8483 | (car (split-string ,compress)) t t nil | ||
| 8484 | (cdr (split-string ,compress))))) | ||
| 8485 | `(lambda (beg end) | ||
| 8486 | (let ((coding-system-for-write 'binary) | ||
| 8487 | (coding-system-for-read 'binary)) | ||
| 8488 | (apply | ||
| 8489 | 'call-process-region beg end | ||
| 8490 | (car (split-string ,compress)) t t nil | ||
| 8491 | (cdr (split-string ,compress)))) | ||
| 8492 | (,coding (point-min) (point-max))))) | ||
| 8493 | ((symbolp coding) | ||
| 8494 | coding) | ||
| 8495 | ((and compress (string-match "decoding" prop)) | ||
| 8496 | (format "(%s | %s >%%s)" coding compress)) | ||
| 8497 | (compress | ||
| 8498 | (format "(%s <%%s | %s)" compress coding)) | ||
| 8499 | ((string-match "decoding" prop) | ||
| 8500 | (format "%s >%%s" coding)) | ||
| 8501 | (t | ||
| 8502 | (format "%s <%%s" coding)))))) | ||
| 8385 | 8503 | ||
| 8386 | (defun tramp-get-method-parameter (method param) | 8504 | (defun tramp-get-method-parameter (method param) |
| 8387 | "Return the method parameter PARAM. | 8505 | "Return the method parameter PARAM. |
| 8388 | If the `tramp-methods' entry does not exist, return NIL." | 8506 | If the `tramp-methods' entry does not exist, return nil." |
| 8389 | (let ((entry (assoc param (assoc method tramp-methods)))) | 8507 | (let ((entry (assoc param (assoc method tramp-methods)))) |
| 8390 | (when entry (cadr entry)))) | 8508 | (when entry (cadr entry)))) |
| 8391 | 8509 | ||