diff options
| author | Michael Albinus | 2010-05-13 22:45:58 +0200 |
|---|---|---|
| committer | Michael Albinus | 2010-05-13 22:45:58 +0200 |
| commit | 3b30ccdab30ffa36d4138d7f9b9d4724f29b4352 (patch) | |
| tree | 3f63b47dfbae4dcff456048129817abb8d35c9a2 | |
| parent | 41d81b80f1a70765aed7503a9c5205c0a030e3ab (diff) | |
| download | emacs-3b30ccdab30ffa36d4138d7f9b9d4724f29b4352.tar.gz emacs-3b30ccdab30ffa36d4138d7f9b9d4724f29b4352.zip | |
* net/tramp.el (with-progress-reporter): Create reporter object
only when the message would be displayed. Handled nested calls.
(tramp-handle-load, tramp-handle-file-local-copy)
(tramp-handle-insert-file-contents, tramp-handle-write-region)
(tramp-maybe-send-script, tramp-find-shell): Use
`with-progress-reporter'.
(tramp-handle-dired-compress-file, tramp-maybe-open-connection):
Fix message text.
* net/tramp-smb.el (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'.
| -rw-r--r-- | lisp/ChangeLog | 16 | ||||
| -rw-r--r-- | lisp/net/tramp-smb.el | 270 | ||||
| -rw-r--r-- | lisp/net/tramp.el | 242 |
3 files changed, 267 insertions, 261 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8c4b4d5c40d..1c640193efd 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | 2010-05-13 Michael Albinus <michael.albinus@gmx.de> | ||
| 2 | |||
| 3 | * net/tramp.el (with-progress-reporter): Create reporter object | ||
| 4 | only when the message would be displayed. Handled nested calls. | ||
| 5 | (tramp-handle-load, tramp-handle-file-local-copy) | ||
| 6 | (tramp-handle-insert-file-contents, tramp-handle-write-region) | ||
| 7 | (tramp-maybe-send-script, tramp-find-shell): Use | ||
| 8 | `with-progress-reporter'. | ||
| 9 | (tramp-handle-dired-compress-file, tramp-maybe-open-connection): | ||
| 10 | Fix message text. | ||
| 11 | |||
| 12 | * net/tramp-smb.el (tramp-smb-handle-copy-file) | ||
| 13 | (tramp-smb-handle-file-local-copy, tramp-smb-handle-rename-file) | ||
| 14 | (tramp-smb-handle-write-region, tramp-smb-maybe-open-connection): | ||
| 15 | Use `with-progress-reporter'. | ||
| 16 | |||
| 1 | 2010-05-13 Agustín Martín <agustin.martin@hispalinux.es> | 17 | 2010-05-13 Agustín Martín <agustin.martin@hispalinux.es> |
| 2 | 18 | ||
| 3 | * ispell.el (ispell-init-process): Do not kill ispell process | 19 | * ispell.el (ispell-init-process): Do not kill ispell process |
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el index 434c2bad20d..00b282b83e3 100644 --- a/lisp/net/tramp-smb.el +++ b/lisp/net/tramp-smb.el | |||
| @@ -334,41 +334,41 @@ KEEP-DATE is not handled in case NEWNAME resides on an SMB server. | |||
| 334 | PRESERVE-UID-GID is completely ignored." | 334 | PRESERVE-UID-GID is completely ignored." |
| 335 | (setq filename (expand-file-name filename) | 335 | (setq filename (expand-file-name filename) |
| 336 | newname (expand-file-name newname)) | 336 | newname (expand-file-name newname)) |
| 337 | (with-progress-reporter | ||
| 338 | (tramp-dissect-file-name (if (file-remote-p filename) filename newname)) | ||
| 339 | 0 (format "Copying %s to %s" filename newname) | ||
| 340 | |||
| 341 | (let ((tmpfile (file-local-copy filename))) | ||
| 342 | |||
| 343 | (if tmpfile | ||
| 344 | ;; Remote filename. | ||
| 345 | (condition-case err | ||
| 346 | (rename-file tmpfile newname ok-if-already-exists) | ||
| 347 | ((error quit) | ||
| 348 | (tramp-compat-delete-file tmpfile 'force) | ||
| 349 | (signal (car err) (cdr err)))) | ||
| 350 | |||
| 351 | ;; Remote newname. | ||
| 352 | (when (file-directory-p newname) | ||
| 353 | (setq newname | ||
| 354 | (expand-file-name (file-name-nondirectory filename) newname))) | ||
| 355 | |||
| 356 | (with-parsed-tramp-file-name newname nil | ||
| 357 | (when (and (not ok-if-already-exists) | ||
| 358 | (file-exists-p newname)) | ||
| 359 | (tramp-error v 'file-already-exists newname)) | ||
| 337 | 360 | ||
| 338 | (let ((tmpfile (file-local-copy filename))) | 361 | ;; We must also flush the cache of the directory, because |
| 339 | 362 | ;; `file-attributes' reads the values from there. | |
| 340 | (if tmpfile | 363 | (tramp-flush-file-property v (file-name-directory localname)) |
| 341 | ;; Remote filename. | 364 | (tramp-flush-file-property v localname) |
| 342 | (condition-case err | 365 | (unless (tramp-smb-get-share v) |
| 343 | (rename-file tmpfile newname ok-if-already-exists) | 366 | (tramp-error |
| 344 | ((error quit) | 367 | v 'file-error "Target `%s' must contain a share name" newname)) |
| 345 | (tramp-compat-delete-file tmpfile 'force) | 368 | (unless (tramp-smb-send-command |
| 346 | (signal (car err) (cdr err)))) | 369 | v (format "put \"%s\" \"%s\"" |
| 347 | 370 | filename (tramp-smb-get-localname v))) | |
| 348 | ;; Remote newname. | 371 | (tramp-error v 'file-error "Cannot copy `%s'" filename)))))) |
| 349 | (when (file-directory-p newname) | ||
| 350 | (setq newname (expand-file-name | ||
| 351 | (file-name-nondirectory filename) newname))) | ||
| 352 | |||
| 353 | (with-parsed-tramp-file-name newname nil | ||
| 354 | (when (and (not ok-if-already-exists) | ||
| 355 | (file-exists-p newname)) | ||
| 356 | (tramp-error v 'file-already-exists newname)) | ||
| 357 | |||
| 358 | ;; We must also flush the cache of the directory, because | ||
| 359 | ;; `file-attributes' reads the values from there. | ||
| 360 | (tramp-flush-file-property v (file-name-directory localname)) | ||
| 361 | (tramp-flush-file-property v localname) | ||
| 362 | (unless (tramp-smb-get-share v) | ||
| 363 | (tramp-error | ||
| 364 | v 'file-error "Target `%s' must contain a share name" newname)) | ||
| 365 | (tramp-message v 0 "Copying file %s to file %s..." filename newname) | ||
| 366 | (if (tramp-smb-send-command | ||
| 367 | v (format "put \"%s\" \"%s\"" | ||
| 368 | filename (tramp-smb-get-localname v))) | ||
| 369 | (tramp-message | ||
| 370 | v 0 "Copying file %s to file %s...done" filename newname) | ||
| 371 | (tramp-error v 'file-error "Cannot copy `%s'" filename))))) | ||
| 372 | 372 | ||
| 373 | ;; KEEP-DATE handling. | 373 | ;; KEEP-DATE handling. |
| 374 | (when keep-date (set-file-times newname (nth 5 (file-attributes filename))))) | 374 | (when keep-date (set-file-times newname (nth 5 (file-attributes filename))))) |
| @@ -605,15 +605,15 @@ PRESERVE-UID-GID is completely ignored." | |||
| 605 | v 'file-error | 605 | v 'file-error |
| 606 | "Cannot make local copy of non-existing file `%s'" filename)) | 606 | "Cannot make local copy of non-existing file `%s'" filename)) |
| 607 | (let ((tmpfile (tramp-compat-make-temp-file filename))) | 607 | (let ((tmpfile (tramp-compat-make-temp-file filename))) |
| 608 | (tramp-message v 4 "Fetching %s to tmp file %s..." filename tmpfile) | 608 | (with-progress-reporter |
| 609 | (if (tramp-smb-send-command | 609 | v 3 (format "Fetching %s to tmp file %s" filename tmpfile) |
| 610 | v (format "get \"%s\" \"%s\"" (tramp-smb-get-localname v) tmpfile)) | 610 | (unless (tramp-smb-send-command |
| 611 | (tramp-message | 611 | v (format "get \"%s\" \"%s\"" |
| 612 | v 4 "Fetching %s to tmp file %s...done" filename tmpfile) | 612 | (tramp-smb-get-localname v) tmpfile)) |
| 613 | ;; Oops, an error. We shall cleanup. | 613 | ;; Oops, an error. We shall cleanup. |
| 614 | (tramp-compat-delete-file tmpfile 'force) | 614 | (tramp-compat-delete-file tmpfile 'force) |
| 615 | (tramp-error | 615 | (tramp-error |
| 616 | v 'file-error "Cannot make local copy of file `%s'" filename)) | 616 | v 'file-error "Cannot make local copy of file `%s'" filename))) |
| 617 | tmpfile))) | 617 | tmpfile))) |
| 618 | 618 | ||
| 619 | ;; This function should return "foo/" for directories and "bar" for | 619 | ;; This function should return "foo/" for directories and "bar" for |
| @@ -850,38 +850,39 @@ target of the symlink differ." | |||
| 850 | "Like `rename-file' for Tramp files." | 850 | "Like `rename-file' for Tramp files." |
| 851 | (setq filename (expand-file-name filename) | 851 | (setq filename (expand-file-name filename) |
| 852 | newname (expand-file-name newname)) | 852 | newname (expand-file-name newname)) |
| 853 | (with-progress-reporter | ||
| 854 | (tramp-dissect-file-name (if (file-remote-p filename) filename newname)) | ||
| 855 | 0 (format "Renaming %s to %s" filename newname) | ||
| 856 | |||
| 857 | (let ((tmpfile (file-local-copy filename))) | ||
| 858 | |||
| 859 | (if tmpfile | ||
| 860 | ;; Remote filename. | ||
| 861 | (condition-case err | ||
| 862 | (rename-file tmpfile newname ok-if-already-exists) | ||
| 863 | ((error quit) | ||
| 864 | (tramp-compat-delete-file tmpfile 'force) | ||
| 865 | (signal (car err) (cdr err)))) | ||
| 866 | |||
| 867 | ;; Remote newname. | ||
| 868 | (when (file-directory-p newname) | ||
| 869 | (setq newname (expand-file-name | ||
| 870 | (file-name-nondirectory filename) newname))) | ||
| 871 | |||
| 872 | (with-parsed-tramp-file-name newname nil | ||
| 873 | (when (and (not ok-if-already-exists) | ||
| 874 | (file-exists-p newname)) | ||
| 875 | (tramp-error v 'file-already-exists newname)) | ||
| 876 | ;; We must also flush the cache of the directory, because | ||
| 877 | ;; `file-attributes' reads the values from there. | ||
| 878 | (tramp-flush-file-property v (file-name-directory localname)) | ||
| 879 | (tramp-flush-file-property v localname) | ||
| 880 | (unless (tramp-smb-send-command | ||
| 881 | v (format "put %s \"%s\"" | ||
| 882 | filename (tramp-smb-get-localname v))) | ||
| 883 | (tramp-error v 'file-error "Cannot rename `%s'" filename))))) | ||
| 853 | 884 | ||
| 854 | (let ((tmpfile (file-local-copy filename))) | 885 | (tramp-compat-delete-file filename 'force))) |
| 855 | |||
| 856 | (if tmpfile | ||
| 857 | ;; Remote filename. | ||
| 858 | (condition-case err | ||
| 859 | (rename-file tmpfile newname ok-if-already-exists) | ||
| 860 | ((error quit) | ||
| 861 | (tramp-compat-delete-file tmpfile 'force) | ||
| 862 | (signal (car err) (cdr err)))) | ||
| 863 | |||
| 864 | ;; Remote newname. | ||
| 865 | (when (file-directory-p newname) | ||
| 866 | (setq newname (expand-file-name | ||
| 867 | (file-name-nondirectory filename) newname))) | ||
| 868 | |||
| 869 | (with-parsed-tramp-file-name newname nil | ||
| 870 | (when (and (not ok-if-already-exists) | ||
| 871 | (file-exists-p newname)) | ||
| 872 | (tramp-error v 'file-already-exists newname)) | ||
| 873 | ;; We must also flush the cache of the directory, because | ||
| 874 | ;; `file-attributes' reads the values from there. | ||
| 875 | (tramp-flush-file-property v (file-name-directory localname)) | ||
| 876 | (tramp-flush-file-property v localname) | ||
| 877 | (tramp-message v 0 "Copying file %s to file %s..." filename newname) | ||
| 878 | (if (tramp-smb-send-command | ||
| 879 | v (format "put %s \"%s\"" filename (tramp-smb-get-localname v))) | ||
| 880 | (tramp-message | ||
| 881 | v 0 "Copying file %s to file %s...done" filename newname) | ||
| 882 | (tramp-error v 'file-error "Cannot rename `%s'" filename))))) | ||
| 883 | |||
| 884 | (tramp-compat-delete-file filename 'force)) | ||
| 885 | 886 | ||
| 886 | (defun tramp-smb-handle-set-file-modes (filename mode) | 887 | (defun tramp-smb-handle-set-file-modes (filename mode) |
| 887 | "Like `set-file-modes' for Tramp files." | 888 | "Like `set-file-modes' for Tramp files." |
| @@ -938,14 +939,14 @@ errors for shares like \"C$/\", which are common in Microsoft Windows." | |||
| 938 | (list start end tmpfile append 'no-message lockname confirm) | 939 | (list start end tmpfile append 'no-message lockname confirm) |
| 939 | (list start end tmpfile append 'no-message lockname))) | 940 | (list start end tmpfile append 'no-message lockname))) |
| 940 | 941 | ||
| 941 | (tramp-message v 5 "Writing tmp file %s to file %s..." tmpfile filename) | 942 | (with-progress-reporter |
| 942 | (unwind-protect | 943 | v 3 (format "Moving tmp file %s to %s" tmpfile filename) |
| 943 | (if (tramp-smb-send-command | 944 | (unwind-protect |
| 944 | v (format "put %s \"%s\"" tmpfile (tramp-smb-get-localname v))) | 945 | (unless (tramp-smb-send-command |
| 945 | (tramp-message | 946 | v (format "put %s \"%s\"" |
| 946 | v 5 "Writing tmp file %s to file %s...done" tmpfile filename) | 947 | tmpfile (tramp-smb-get-localname v))) |
| 947 | (tramp-error v 'file-error "Cannot write `%s'" filename)) | 948 | (tramp-error v 'file-error "Cannot write `%s'" filename)) |
| 948 | (tramp-compat-delete-file tmpfile 'force)) | 949 | (tramp-compat-delete-file tmpfile 'force))) |
| 949 | 950 | ||
| 950 | (unless (equal curbuf (current-buffer)) | 951 | (unless (equal curbuf (current-buffer)) |
| 951 | (tramp-error | 952 | (tramp-error |
| @@ -1302,60 +1303,57 @@ connection if a previous connection has died for some reason." | |||
| 1302 | (setq args (append args (list "-s" tramp-smb-conf)))) | 1303 | (setq args (append args (list "-s" tramp-smb-conf)))) |
| 1303 | 1304 | ||
| 1304 | ;; OK, let's go. | 1305 | ;; OK, let's go. |
| 1305 | (tramp-message | 1306 | (with-progress-reporter |
| 1306 | vec 3 "Opening connection for //%s%s/%s..." | 1307 | vec 3 |
| 1307 | (if (not (zerop (length user))) (concat user "@") "") | 1308 | (format "Opening connection for //%s%s/%s" |
| 1308 | host (or share "")) | 1309 | (if (not (zerop (length user))) (concat user "@") "") |
| 1309 | 1310 | host (or share "")) | |
| 1310 | (let* ((coding-system-for-read nil) | 1311 | |
| 1311 | (process-connection-type tramp-process-connection-type) | 1312 | (let* ((coding-system-for-read nil) |
| 1312 | (p (let ((default-directory | 1313 | (process-connection-type tramp-process-connection-type) |
| 1313 | (tramp-compat-temporary-file-directory))) | 1314 | (p (let ((default-directory |
| 1314 | (apply #'start-process | 1315 | (tramp-compat-temporary-file-directory))) |
| 1315 | (tramp-buffer-name vec) (tramp-get-buffer vec) | 1316 | (apply #'start-process |
| 1316 | tramp-smb-program args)))) | 1317 | (tramp-buffer-name vec) (tramp-get-buffer vec) |
| 1317 | 1318 | tramp-smb-program args)))) | |
| 1318 | (tramp-message | 1319 | |
| 1319 | vec 6 "%s" (mapconcat 'identity (process-command p) " ")) | 1320 | (tramp-message |
| 1320 | (tramp-set-process-query-on-exit-flag p nil) | 1321 | vec 6 "%s" (mapconcat 'identity (process-command p) " ")) |
| 1321 | 1322 | (tramp-set-process-query-on-exit-flag p nil) | |
| 1322 | ;; Set variables for computing the prompt for reading password. | 1323 | |
| 1323 | (setq tramp-current-method tramp-smb-method | 1324 | ;; Set variables for computing the prompt for reading password. |
| 1324 | tramp-current-user user | 1325 | (setq tramp-current-method tramp-smb-method |
| 1325 | tramp-current-host host) | 1326 | tramp-current-user user |
| 1326 | 1327 | tramp-current-host host) | |
| 1327 | ;; Play login scenario. | 1328 | |
| 1328 | (tramp-process-actions | 1329 | ;; Play login scenario. |
| 1329 | p vec | 1330 | (tramp-process-actions |
| 1330 | (if share | 1331 | p vec |
| 1331 | tramp-smb-actions-with-share | 1332 | (if share |
| 1332 | tramp-smb-actions-without-share)) | 1333 | tramp-smb-actions-with-share |
| 1333 | 1334 | tramp-smb-actions-without-share)) | |
| 1334 | ;; Check server version. | 1335 | |
| 1335 | (with-current-buffer (tramp-get-connection-buffer vec) | 1336 | ;; Check server version. |
| 1336 | (goto-char (point-min)) | 1337 | (with-current-buffer (tramp-get-connection-buffer vec) |
| 1337 | (search-forward-regexp | 1338 | (goto-char (point-min)) |
| 1338 | "Domain=\\[[^]]*\\] OS=\\[[^]]*\\] Server=\\[[^]]*\\]" nil t) | 1339 | (search-forward-regexp |
| 1339 | (let ((smbserver-version (match-string 0))) | 1340 | "Domain=\\[[^]]*\\] OS=\\[[^]]*\\] Server=\\[[^]]*\\]" nil t) |
| 1340 | (unless | 1341 | (let ((smbserver-version (match-string 0))) |
| 1341 | (string-equal | 1342 | (unless |
| 1342 | smbserver-version | 1343 | (string-equal |
| 1343 | (tramp-get-connection-property | 1344 | smbserver-version |
| 1344 | vec "smbserver-version" smbserver-version)) | 1345 | (tramp-get-connection-property |
| 1345 | (tramp-flush-directory-property vec "") | 1346 | vec "smbserver-version" smbserver-version)) |
| 1346 | (tramp-flush-connection-property vec)) | 1347 | (tramp-flush-directory-property vec "") |
| 1347 | (tramp-set-connection-property | 1348 | (tramp-flush-connection-property vec)) |
| 1348 | vec "smbserver-version" smbserver-version))) | 1349 | (tramp-set-connection-property |
| 1349 | 1350 | vec "smbserver-version" smbserver-version))) | |
| 1350 | ;; Set chunksize. Otherwise, `tramp-send-string' might | 1351 | |
| 1351 | ;; try it itself. | 1352 | ;; Set chunksize. Otherwise, `tramp-send-string' might |
| 1352 | (tramp-set-connection-property p "smb-share" share) | 1353 | ;; try it itself. |
| 1353 | (tramp-set-connection-property p "chunksize" tramp-chunksize) | 1354 | (tramp-set-connection-property p "smb-share" share) |
| 1354 | 1355 | (tramp-set-connection-property | |
| 1355 | (tramp-message | 1356 | p "chunksize" tramp-chunksize)))))))) |
| 1356 | vec 3 "Opening connection for //%s%s/%s...done" | ||
| 1357 | (if (not (zerop (length user))) (concat user "@") "") | ||
| 1358 | host (or share "")))))))) | ||
| 1359 | 1357 | ||
| 1360 | ;; We don't use timeouts. If needed, the caller shall wrap around. | 1358 | ;; We don't use timeouts. If needed, the caller shall wrap around. |
| 1361 | (defun tramp-smb-wait-for-output (vec) | 1359 | (defun tramp-smb-wait-for-output (vec) |
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 2da11bda834..c5addae8e5d 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -2271,14 +2271,18 @@ FILE must be a local file name on a connection identified via VEC." | |||
| 2271 | (tramp-message ,vec ,level "%s..." ,message) | 2271 | (tramp-message ,vec ,level "%s..." ,message) |
| 2272 | ;; We start a pulsing progress reporter after 3 seconds. Feature | 2272 | ;; We start a pulsing progress reporter after 3 seconds. Feature |
| 2273 | ;; introduced in Emacs 24.1. | 2273 | ;; introduced in Emacs 24.1. |
| 2274 | (when (<= ,level tramp-verbose) | 2274 | (when (and tramp-message-show-message |
| 2275 | ;; Display only when there is a minimum level. | ||
| 2276 | (<= ,level (min tramp-verbose 3))) | ||
| 2275 | (condition-case nil | 2277 | (condition-case nil |
| 2276 | (setq pr (tramp-compat-funcall 'make-progress-reporter ,message) | 2278 | (setq pr (tramp-compat-funcall 'make-progress-reporter ,message) |
| 2277 | tm (if pr (run-at-time 3 0.1 'progress-reporter-update pr))) | 2279 | tm (if pr (run-at-time 3 0.1 'progress-reporter-update pr))) |
| 2278 | (error nil))) | 2280 | (error nil))) |
| 2279 | (unwind-protect | 2281 | (unwind-protect |
| 2280 | ;; Execute the body. | 2282 | ;; Execute the body. |
| 2281 | (progn ,@body) | 2283 | (let ((tramp-message-show-message |
| 2284 | (and tramp-message-show-message (not tm)))) | ||
| 2285 | ,@body) | ||
| 2282 | ;; Stop progress reporter. | 2286 | ;; Stop progress reporter. |
| 2283 | (if tm (tramp-compat-funcall 'cancel-timer tm)) | 2287 | (if tm (tramp-compat-funcall 'cancel-timer tm)) |
| 2284 | (tramp-message ,vec ,level "%s...done" ,message)))) | 2288 | (tramp-message ,vec ,level "%s...done" ,message)))) |
| @@ -2558,13 +2562,13 @@ target of the symlink differ." | |||
| 2558 | (tramp-error v 'file-error "Cannot load nonexistent file `%s'" file))) | 2562 | (tramp-error v 'file-error "Cannot load nonexistent file `%s'" file))) |
| 2559 | (if (not (file-exists-p file)) | 2563 | (if (not (file-exists-p file)) |
| 2560 | nil | 2564 | nil |
| 2561 | (unless nomessage (tramp-message v 0 "Loading %s..." file)) | 2565 | (let ((tramp-message-show-message (not nomessage))) |
| 2562 | (let ((local-copy (file-local-copy file))) | 2566 | (with-progress-reporter v 0 (format "Loading %s" file) |
| 2563 | ;; MUST-SUFFIX doesn't exist on XEmacs, so let it default to nil. | 2567 | (let ((local-copy (file-local-copy file))) |
| 2564 | (unwind-protect | 2568 | ;; MUST-SUFFIX doesn't exist on XEmacs, so let it default to nil. |
| 2565 | (load local-copy noerror t t) | 2569 | (unwind-protect |
| 2566 | (tramp-compat-delete-file local-copy 'force))) | 2570 | (load local-copy noerror t t) |
| 2567 | (unless nomessage (tramp-message v 0 "Loading %s...done" file)) | 2571 | (tramp-compat-delete-file local-copy 'force))))) |
| 2568 | t))) | 2572 | t))) |
| 2569 | 2573 | ||
| 2570 | ;; Localname manipulation functions that grok Tramp localnames... | 2574 | ;; Localname manipulation functions that grok Tramp localnames... |
| @@ -4153,7 +4157,7 @@ This is like `dired-recursive-delete-directory' for Tramp files." | |||
| 4153 | nil) | 4157 | nil) |
| 4154 | ((and suffix (nth 2 suffix)) | 4158 | ((and suffix (nth 2 suffix)) |
| 4155 | ;; We found an uncompression rule. | 4159 | ;; We found an uncompression rule. |
| 4156 | (with-progress-reporter v 0 (format "Uncompressing %s..." file) | 4160 | (with-progress-reporter v 0 (format "Uncompressing %s" file) |
| 4157 | (when (zerop | 4161 | (when (zerop |
| 4158 | (tramp-send-command-and-check | 4162 | (tramp-send-command-and-check |
| 4159 | v (concat (nth 2 suffix) " " | 4163 | v (concat (nth 2 suffix) " " |
| @@ -4165,7 +4169,7 @@ This is like `dired-recursive-delete-directory' for Tramp files." | |||
| 4165 | (t | 4169 | (t |
| 4166 | ;; We don't recognize the file as compressed, so compress it. | 4170 | ;; We don't recognize the file as compressed, so compress it. |
| 4167 | ;; Try gzip. | 4171 | ;; Try gzip. |
| 4168 | (with-progress-reporter v 0 (format "Compressing %s..." file) | 4172 | (with-progress-reporter v 0 (format "Compressing %s" file) |
| 4169 | (when (zerop | 4173 | (when (zerop |
| 4170 | (tramp-send-command-and-check | 4174 | (tramp-send-command-and-check |
| 4171 | v (concat "gzip -f " | 4175 | v (concat "gzip -f " |
| @@ -4747,11 +4751,11 @@ Lisp error raised when PROGRAM is nil is trapped also, returning 1." | |||
| 4747 | ;; Use inline encoding for file transfer. | 4751 | ;; Use inline encoding for file transfer. |
| 4748 | (rem-enc | 4752 | (rem-enc |
| 4749 | (save-excursion | 4753 | (save-excursion |
| 4750 | (tramp-message v 5 "Encoding remote file %s..." filename) | 4754 | (with-progress-reporter |
| 4751 | (tramp-barf-unless-okay | 4755 | v 5 (format "Encoding remote file %s" filename) |
| 4752 | v (format rem-enc (tramp-shell-quote-argument localname)) | 4756 | (tramp-barf-unless-okay |
| 4753 | "Encoding remote file failed") | 4757 | v (format rem-enc (tramp-shell-quote-argument localname)) |
| 4754 | (tramp-message v 5 "Encoding remote file %s...done" filename) | 4758 | "Encoding remote file failed")) |
| 4755 | 4759 | ||
| 4756 | (if (functionp loc-dec) | 4760 | (if (functionp loc-dec) |
| 4757 | ;; If local decoding is a function, we call it. We | 4761 | ;; If local decoding is a function, we call it. We |
| @@ -4761,15 +4765,15 @@ Lisp error raised when PROGRAM is nil is trapped also, returning 1." | |||
| 4761 | (with-temp-buffer | 4765 | (with-temp-buffer |
| 4762 | (set-buffer-multibyte nil) | 4766 | (set-buffer-multibyte nil) |
| 4763 | (insert-buffer-substring (tramp-get-buffer v)) | 4767 | (insert-buffer-substring (tramp-get-buffer v)) |
| 4764 | (tramp-message | 4768 | (with-progress-reporter |
| 4765 | v 5 "Decoding remote file %s with function %s..." | 4769 | v 3 (format "Decoding remote file %s with function %s" |
| 4766 | filename loc-dec) | 4770 | filename loc-dec) |
| 4767 | (funcall loc-dec (point-min) (point-max)) | 4771 | (funcall loc-dec (point-min) (point-max)) |
| 4768 | ;; Unset `file-name-handler-alist'. Otherwise, | 4772 | ;; Unset `file-name-handler-alist'. Otherwise, |
| 4769 | ;; epa-file gets confused. | 4773 | ;; epa-file gets confused. |
| 4770 | (let (file-name-handler-alist | 4774 | (let (file-name-handler-alist |
| 4771 | (coding-system-for-write 'binary)) | 4775 | (coding-system-for-write 'binary)) |
| 4772 | (write-region (point-min) (point-max) tmpfile))) | 4776 | (write-region (point-min) (point-max) tmpfile)))) |
| 4773 | 4777 | ||
| 4774 | ;; If tramp-decoding-function is not defined for this | 4778 | ;; If tramp-decoding-function is not defined for this |
| 4775 | ;; method, we invoke tramp-decoding-command instead. | 4779 | ;; method, we invoke tramp-decoding-command instead. |
| @@ -4779,14 +4783,14 @@ Lisp error raised when PROGRAM is nil is trapped also, returning 1." | |||
| 4779 | (let (file-name-handler-alist | 4783 | (let (file-name-handler-alist |
| 4780 | (coding-system-for-write 'binary)) | 4784 | (coding-system-for-write 'binary)) |
| 4781 | (write-region (point-min) (point-max) tmpfile2)) | 4785 | (write-region (point-min) (point-max) tmpfile2)) |
| 4782 | (tramp-message | 4786 | (with-progress-reporter |
| 4783 | v 5 "Decoding remote file %s with command %s..." | 4787 | v 3 (format "Decoding remote file %s with command %s" |
| 4784 | filename loc-dec) | 4788 | filename loc-dec) |
| 4785 | (unwind-protect | 4789 | (unwind-protect |
| 4786 | (tramp-call-local-coding-command loc-dec tmpfile2 tmpfile) | 4790 | (tramp-call-local-coding-command |
| 4787 | (tramp-compat-delete-file tmpfile2 'force)))) | 4791 | loc-dec tmpfile2 tmpfile) |
| 4792 | (tramp-compat-delete-file tmpfile2 'force))))) | ||
| 4788 | 4793 | ||
| 4789 | (tramp-message v 5 "Decoding remote file %s...done" filename) | ||
| 4790 | ;; Set proper permissions. | 4794 | ;; Set proper permissions. |
| 4791 | (set-file-modes tmpfile (tramp-default-file-modes filename)) | 4795 | (set-file-modes tmpfile (tramp-default-file-modes filename)) |
| 4792 | ;; Set local user ownership. | 4796 | ;; Set local user ownership. |
| @@ -4842,7 +4846,7 @@ coding system might not be determined. This function repairs it." | |||
| 4842 | "Like `insert-file-contents' for Tramp files." | 4846 | "Like `insert-file-contents' for Tramp files." |
| 4843 | (barf-if-buffer-read-only) | 4847 | (barf-if-buffer-read-only) |
| 4844 | (setq filename (expand-file-name filename)) | 4848 | (setq filename (expand-file-name filename)) |
| 4845 | (let (coding-system-used result local-copy remote-copy) | 4849 | (let (result local-copy remote-copy) |
| 4846 | (with-parsed-tramp-file-name filename nil | 4850 | (with-parsed-tramp-file-name filename nil |
| 4847 | (unwind-protect | 4851 | (unwind-protect |
| 4848 | (if (not (file-exists-p filename)) | 4852 | (if (not (file-exists-p filename)) |
| @@ -4913,27 +4917,16 @@ coding system might not be determined. This function repairs it." | |||
| 4913 | (setq tramp-temp-buffer-file-name local-copy) | 4917 | (setq tramp-temp-buffer-file-name local-copy) |
| 4914 | (put 'tramp-temp-buffer-file-name 'permanent-local t)) | 4918 | (put 'tramp-temp-buffer-file-name 'permanent-local t)) |
| 4915 | 4919 | ||
| 4916 | (tramp-message | 4920 | (with-progress-reporter |
| 4917 | v 4 "Inserting local temp file `%s'..." local-copy) | 4921 | v 3 (format "Inserting local temp file `%s'" local-copy) |
| 4918 | 4922 | ;; We must ensure that `file-coding-system-alist' | |
| 4919 | ;; We must ensure that `file-coding-system-alist' | 4923 | ;; matches `local-copy'. |
| 4920 | ;; matches `local-copy'. | 4924 | (let ((file-coding-system-alist |
| 4921 | (let ((file-coding-system-alist | 4925 | (tramp-find-file-name-coding-system-alist |
| 4922 | (tramp-find-file-name-coding-system-alist | 4926 | filename local-copy))) |
| 4923 | filename local-copy))) | 4927 | (setq result |
| 4924 | (setq result | 4928 | (insert-file-contents |
| 4925 | (insert-file-contents | 4929 | local-copy nil nil nil replace)))))) |
| 4926 | local-copy nil nil nil replace)) | ||
| 4927 | ;; Now `last-coding-system-used' has right value. | ||
| 4928 | ;; Remember it. | ||
| 4929 | (when (boundp 'last-coding-system-used) | ||
| 4930 | (setq coding-system-used | ||
| 4931 | (symbol-value 'last-coding-system-used)))) | ||
| 4932 | |||
| 4933 | (tramp-message | ||
| 4934 | v 4 "Inserting local temp file `%s'...done" local-copy) | ||
| 4935 | (when (boundp 'last-coding-system-used) | ||
| 4936 | (set 'last-coding-system-used coding-system-used)))) | ||
| 4937 | 4930 | ||
| 4938 | ;; Save exit. | 4931 | ;; Save exit. |
| 4939 | (progn | 4932 | (progn |
| @@ -5193,15 +5186,14 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file." | |||
| 5193 | ;; Use inline file transfer. | 5186 | ;; Use inline file transfer. |
| 5194 | (rem-dec | 5187 | (rem-dec |
| 5195 | ;; Encode tmpfile. | 5188 | ;; Encode tmpfile. |
| 5196 | (tramp-message v 5 "Encoding region...") | ||
| 5197 | (unwind-protect | 5189 | (unwind-protect |
| 5198 | (with-temp-buffer | 5190 | (with-temp-buffer |
| 5199 | (set-buffer-multibyte nil) | 5191 | (set-buffer-multibyte nil) |
| 5200 | ;; Use encoding function or command. | 5192 | ;; Use encoding function or command. |
| 5201 | (if (functionp loc-enc) | 5193 | (if (functionp loc-enc) |
| 5202 | (progn | 5194 | (with-progress-reporter |
| 5203 | (tramp-message | 5195 | v 3 (format "Encoding region using function `%s'" |
| 5204 | v 5 "Encoding region using function `%s'..." loc-enc) | 5196 | loc-enc) |
| 5205 | (let ((coding-system-for-read 'binary)) | 5197 | (let ((coding-system-for-read 'binary)) |
| 5206 | (insert-file-contents-literally tmpfile)) | 5198 | (insert-file-contents-literally tmpfile)) |
| 5207 | ;; The following `let' is a workaround for the | 5199 | ;; The following `let' is a workaround for the |
| @@ -5217,59 +5209,61 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file." | |||
| 5217 | (tramp-compat-temporary-file-directory))) | 5209 | (tramp-compat-temporary-file-directory))) |
| 5218 | (funcall loc-enc (point-min) (point-max)))) | 5210 | (funcall loc-enc (point-min) (point-max)))) |
| 5219 | 5211 | ||
| 5220 | (tramp-message | 5212 | (with-progress-reporter |
| 5221 | v 5 "Encoding region using command `%s'..." loc-enc) | 5213 | v 3 (format "Encoding region using command `%s'" |
| 5222 | (unless (zerop (tramp-call-local-coding-command | 5214 | loc-enc) |
| 5223 | loc-enc tmpfile t)) | 5215 | (unless (zerop (tramp-call-local-coding-command |
| 5224 | (tramp-error | 5216 | loc-enc tmpfile t)) |
| 5225 | v 'file-error | 5217 | (tramp-error |
| 5226 | "Cannot write to `%s', local encoding command `%s' failed" | 5218 | v 'file-error |
| 5227 | filename loc-enc))) | 5219 | (concat "Cannot write to `%s', " |
| 5220 | "local encoding command `%s' failed") | ||
| 5221 | filename loc-enc)))) | ||
| 5228 | 5222 | ||
| 5229 | ;; Send buffer into remote decoding command which | 5223 | ;; Send buffer into remote decoding command which |
| 5230 | ;; writes to remote file. Because this happens on | 5224 | ;; writes to remote file. Because this happens on |
| 5231 | ;; the remote host, we cannot use the function. | 5225 | ;; the remote host, we cannot use the function. |
| 5232 | (goto-char (point-max)) | 5226 | (with-progress-reporter |
| 5233 | (unless (bolp) (newline)) | 5227 | v 3 |
| 5234 | (tramp-message | 5228 | (format "Decoding region into remote file %s" filename) |
| 5235 | v 5 "Decoding region into remote file %s..." filename) | 5229 | (goto-char (point-max)) |
| 5236 | (tramp-send-command | 5230 | (unless (bolp) (newline)) |
| 5237 | v | 5231 | (tramp-send-command |
| 5238 | (format | 5232 | v |
| 5239 | (concat rem-dec " <<'EOF'\n%sEOF") | 5233 | (format |
| 5240 | (tramp-shell-quote-argument localname) | 5234 | (concat rem-dec " <<'EOF'\n%sEOF") |
| 5241 | (buffer-string))) | 5235 | (tramp-shell-quote-argument localname) |
| 5242 | (tramp-barf-unless-okay | 5236 | (buffer-string))) |
| 5243 | v nil | 5237 | (tramp-barf-unless-okay |
| 5244 | "Couldn't write region to `%s', decode using `%s' failed" | 5238 | v nil |
| 5245 | filename rem-dec) | 5239 | "Couldn't write region to `%s', decode using `%s' failed" |
| 5246 | ;; When `file-precious-flag' is set, the region is | 5240 | filename rem-dec) |
| 5247 | ;; written to a temporary file. Check that the | 5241 | ;; When `file-precious-flag' is set, the region is |
| 5248 | ;; checksum is equal to that from the local tmpfile. | 5242 | ;; written to a temporary file. Check that the |
| 5249 | (when file-precious-flag | 5243 | ;; checksum is equal to that from the local tmpfile. |
| 5250 | (erase-buffer) | 5244 | (when file-precious-flag |
| 5251 | (and | 5245 | (erase-buffer) |
| 5252 | ;; cksum runs locally, if possible. | 5246 | (and |
| 5253 | (zerop (tramp-local-call-process "cksum" tmpfile t)) | 5247 | ;; cksum runs locally, if possible. |
| 5254 | ;; cksum runs remotely. | 5248 | (zerop (tramp-local-call-process "cksum" tmpfile t)) |
| 5255 | (zerop | 5249 | ;; cksum runs remotely. |
| 5256 | (tramp-send-command-and-check | 5250 | (zerop |
| 5257 | v | 5251 | (tramp-send-command-and-check |
| 5258 | (format | 5252 | v |
| 5259 | "cksum <%s" (tramp-shell-quote-argument localname)))) | 5253 | (format |
| 5260 | ;; ... they are different. | 5254 | "cksum <%s" |
| 5261 | (not | 5255 | (tramp-shell-quote-argument localname)))) |
| 5262 | (string-equal | 5256 | ;; ... they are different. |
| 5263 | (buffer-string) | 5257 | (not |
| 5264 | (with-current-buffer (tramp-get-buffer v) | 5258 | (string-equal |
| 5265 | (buffer-string)))) | 5259 | (buffer-string) |
| 5266 | (tramp-error | 5260 | (with-current-buffer (tramp-get-buffer v) |
| 5267 | v 'file-error | 5261 | (buffer-string)))) |
| 5268 | (concat "Couldn't write region to `%s'," | 5262 | (tramp-error |
| 5269 | " decode using `%s' failed") | 5263 | v 'file-error |
| 5270 | filename rem-dec))) | 5264 | (concat "Couldn't write region to `%s'," |
| 5271 | (tramp-message | 5265 | " decode using `%s' failed") |
| 5272 | v 5 "Decoding region into remote file %s...done" filename)) | 5266 | filename rem-dec))))) |
| 5273 | 5267 | ||
| 5274 | ;; Save exit. | 5268 | ;; Save exit. |
| 5275 | (tramp-compat-delete-file tmpfile 'force))) | 5269 | (tramp-compat-delete-file tmpfile 'force))) |
| @@ -6286,14 +6280,13 @@ Only send the definition if it has not already been done." | |||
| 6286 | (let* ((p (tramp-get-connection-process vec)) | 6280 | (let* ((p (tramp-get-connection-process vec)) |
| 6287 | (scripts (tramp-get-connection-property p "scripts" nil))) | 6281 | (scripts (tramp-get-connection-property p "scripts" nil))) |
| 6288 | (unless (member name scripts) | 6282 | (unless (member name scripts) |
| 6289 | (tramp-message vec 5 "Sending script `%s'..." name) | 6283 | (with-progress-reporter vec 5 (format "Sending script `%s'" name) |
| 6290 | ;; The script could contain a call of Perl. This is masked with `%s'. | 6284 | ;; The script could contain a call of Perl. This is masked with `%s'. |
| 6291 | (tramp-send-command-and-check | 6285 | (tramp-send-command-and-check |
| 6292 | vec | 6286 | vec |
| 6293 | (format "%s () {\n%s\n}" name | 6287 | (format "%s () {\n%s\n}" name |
| 6294 | (format script (tramp-get-remote-perl vec)))) | 6288 | (format script (tramp-get-remote-perl vec)))) |
| 6295 | (tramp-set-connection-property p "scripts" (cons name scripts)) | 6289 | (tramp-set-connection-property p "scripts" (cons name scripts)))))) |
| 6296 | (tramp-message vec 5 "Sending script `%s'...done." name)))) | ||
| 6297 | 6290 | ||
| 6298 | (defun tramp-set-auto-save () | 6291 | (defun tramp-set-auto-save () |
| 6299 | (when (and ;; ange-ftp has its own auto-save mechanism | 6292 | (when (and ;; ange-ftp has its own auto-save mechanism |
| @@ -6572,7 +6565,7 @@ file exists and nonzero exit status otherwise." | |||
| 6572 | (setq extra-args (cdr item)))) | 6565 | (setq extra-args (cdr item)))) |
| 6573 | (when extra-args (setq shell (concat shell " " extra-args)))) | 6566 | (when extra-args (setq shell (concat shell " " extra-args)))) |
| 6574 | (tramp-message | 6567 | (tramp-message |
| 6575 | vec 5 "Starting remote shell `%s' for tilde expansion..." shell) | 6568 | vec 5 "Starting remote shell `%s' for tilde expansion" shell) |
| 6576 | (let ((tramp-end-of-output tramp-initial-end-of-output)) | 6569 | (let ((tramp-end-of-output tramp-initial-end-of-output)) |
| 6577 | (tramp-send-command | 6570 | (tramp-send-command |
| 6578 | vec | 6571 | vec |
| @@ -6580,13 +6573,12 @@ file exists and nonzero exit status otherwise." | |||
| 6580 | (shell-quote-argument tramp-end-of-output) shell) | 6573 | (shell-quote-argument tramp-end-of-output) shell) |
| 6581 | t)) | 6574 | t)) |
| 6582 | ;; Setting prompts. | 6575 | ;; Setting prompts. |
| 6583 | (tramp-message vec 5 "Setting remote shell prompt...") | 6576 | (with-progress-reporter vec 5 (format "Setting remote shell prompt") |
| 6584 | (tramp-send-command | 6577 | (tramp-send-command |
| 6585 | vec (format "PS1=%s" (shell-quote-argument tramp-end-of-output)) t) | 6578 | vec (format "PS1=%s" (shell-quote-argument tramp-end-of-output)) t) |
| 6586 | (tramp-send-command vec "PS2=''" t) | 6579 | (tramp-send-command vec "PS2=''" t) |
| 6587 | (tramp-send-command vec "PS3=''" t) | 6580 | (tramp-send-command vec "PS3=''" t) |
| 6588 | (tramp-send-command vec "PROMPT_COMMAND=''" t) | 6581 | (tramp-send-command vec "PROMPT_COMMAND=''" t))) |
| 6589 | (tramp-message vec 5 "Setting remote shell prompt...done")) | ||
| 6590 | 6582 | ||
| 6591 | (t (tramp-message | 6583 | (t (tramp-message |
| 6592 | vec 5 "Remote `%s' groks tilde expansion, good" | 6584 | vec 5 "Remote `%s' groks tilde expansion, good" |
| @@ -7423,11 +7415,11 @@ connection if a previous connection has died for some reason." | |||
| 7423 | (tramp-get-buffer vec) | 7415 | (tramp-get-buffer vec) |
| 7424 | (if (zerop (length (tramp-file-name-user vec))) | 7416 | (if (zerop (length (tramp-file-name-user vec))) |
| 7425 | (tramp-message | 7417 | (tramp-message |
| 7426 | vec 3 "Opening connection for %s using %s..." | 7418 | vec 3 "Opening connection for %s using %s" |
| 7427 | (tramp-file-name-host vec) | 7419 | (tramp-file-name-host vec) |
| 7428 | (tramp-file-name-method vec)) | 7420 | (tramp-file-name-method vec)) |
| 7429 | (tramp-message | 7421 | (tramp-message |
| 7430 | vec 3 "Opening connection for %s@%s using %s..." | 7422 | vec 3 "Opening connection for %s@%s using %s" |
| 7431 | (tramp-file-name-user vec) | 7423 | (tramp-file-name-user vec) |
| 7432 | (tramp-file-name-host vec) | 7424 | (tramp-file-name-host vec) |
| 7433 | (tramp-file-name-method vec))) | 7425 | (tramp-file-name-method vec))) |