Mercurial > emacs
comparison lisp/net/tramp-smb.el @ 85024:ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
(tramp-file-name-handler-alist): Add
`tramp-handle-insert-file-contents-literally'. Neded for XEmacs.
(tramp-make-temp-file): Use `make-temp-name'. `make-temp-file',
used before, creates the file already, which is not desired.
(tramp-do-copy-or-rename-file-directly): Simplify handling of
temporary file.
(tramp-handle-insert-file-contents): Assign the result in the
short track case.
(tramp-handle-insert-file-contents-literally): New defun.
(tramp-completion-mode-p): Revert change from 2007-09-24.
Checking for `return' etc as last character is not sufficient, for
example in dired-mode when entering <g> (revert-buffer) or
<s> (dired-sort).
* net/tramp-compat.el (top): Add also compatibility code for loading
appropriate timer package.
(tramp-compat-copy-tree): Check for `subrp' and `symbol-file' in
order to avoid autoloading problems.
* net/tramp-fish.el:
* net/tramp-smb.el: Move further compatibility code to
tramp-compat.el.
* net/tramp-ftp.el (tramp-ftp-file-name-handler): Handle the case
where the second parameter of `copy-file' or `rename-file' is a
remote file but not via ftp.
author | Michael Albinus <michael.albinus@gmx.de> |
---|---|
date | Wed, 03 Oct 2007 10:54:03 +0000 |
parents | f7642749252b |
children | a42b8750a992 |
comparison
equal
deleted
inserted
replaced
85023:0161d8024935 | 85024:ef71cdab0d5c |
---|---|
29 ;;; Code: | 29 ;;; Code: |
30 | 30 |
31 (require 'tramp) | 31 (require 'tramp) |
32 (require 'tramp-cache) | 32 (require 'tramp-cache) |
33 (require 'tramp-compat) | 33 (require 'tramp-compat) |
34 | |
35 ;; Pacify byte-compiler | |
36 (eval-when-compile | |
37 (require 'cl) | |
38 (require 'custom)) | |
39 | 34 |
40 ;; Define SMB method ... | 35 ;; Define SMB method ... |
41 (defcustom tramp-smb-method "smb" | 36 (defcustom tramp-smb-method "smb" |
42 "*Method to connect SAMBA and M$ SMB servers." | 37 "*Method to connect SAMBA and M$ SMB servers." |
43 :group 'tramp | 38 :group 'tramp |
374 | 369 |
375 (defun tramp-smb-handle-file-local-copy (filename) | 370 (defun tramp-smb-handle-file-local-copy (filename) |
376 "Like `file-local-copy' for Tramp files." | 371 "Like `file-local-copy' for Tramp files." |
377 (with-parsed-tramp-file-name filename nil | 372 (with-parsed-tramp-file-name filename nil |
378 (let ((file (tramp-smb-get-localname localname t)) | 373 (let ((file (tramp-smb-get-localname localname t)) |
379 (tmpfil (tramp-make-temp-file filename))) | 374 (tmpfile (tramp-make-temp-file filename))) |
380 (unless (file-exists-p filename) | 375 (unless (file-exists-p filename) |
381 (tramp-error | 376 (tramp-error |
382 v 'file-error | 377 v 'file-error |
383 "Cannot make local copy of non-existing file `%s'" filename)) | 378 "Cannot make local copy of non-existing file `%s'" filename)) |
384 (tramp-message v 4 "Fetching %s to tmp file %s..." filename tmpfil) | 379 (tramp-message v 4 "Fetching %s to tmp file %s..." filename tmpfile) |
385 (if (tramp-smb-send-command v (format "get \"%s\" %s" file tmpfil)) | 380 (if (tramp-smb-send-command v (format "get \"%s\" %s" file tmpfile)) |
386 (tramp-message | 381 (tramp-message |
387 v 4 "Fetching %s to tmp file %s...done" filename tmpfil) | 382 v 4 "Fetching %s to tmp file %s...done" filename tmpfile) |
388 (tramp-error | 383 (tramp-error |
389 v 'file-error | 384 v 'file-error |
390 "Cannot make local copy of file `%s'" filename)) | 385 "Cannot make local copy of file `%s'" filename)) |
391 tmpfil))) | 386 tmpfile))) |
392 | 387 |
393 ;; This function should return "foo/" for directories and "bar" for | 388 ;; This function should return "foo/" for directories and "bar" for |
394 ;; files. | 389 ;; files. |
395 (defun tramp-smb-handle-file-name-all-completions (filename directory) | 390 (defun tramp-smb-handle-file-name-all-completions (filename directory) |
396 "Like `file-name-all-completions' for Tramp files." | 391 "Like `file-name-all-completions' for Tramp files." |
578 (setq filename (expand-file-name filename)) | 573 (setq filename (expand-file-name filename)) |
579 (with-parsed-tramp-file-name filename nil | 574 (with-parsed-tramp-file-name filename nil |
580 (unless (eq append nil) | 575 (unless (eq append nil) |
581 (tramp-error | 576 (tramp-error |
582 v 'file-error "Cannot append to file using tramp (`%s')" filename)) | 577 v 'file-error "Cannot append to file using tramp (`%s')" filename)) |
583 ;; XEmacs takes a coding system as the seventh argument, not `confirm' | 578 ;; XEmacs takes a coding system as the seventh argument, not `confirm'. |
584 (when (and (not (featurep 'xemacs)) | 579 (when (and (not (featurep 'xemacs)) |
585 confirm (file-exists-p filename)) | 580 confirm (file-exists-p filename)) |
586 (unless (y-or-n-p (format "File %s exists; overwrite anyway? " | 581 (unless (y-or-n-p (format "File %s exists; overwrite anyway? " |
587 filename)) | 582 filename)) |
588 (tramp-error v 'file-error "File not overwritten"))) | 583 (tramp-error v 'file-error "File not overwritten"))) |
590 ;; file-attributes reads the values from there. | 585 ;; file-attributes reads the values from there. |
591 (tramp-flush-file-property v (file-name-directory localname)) | 586 (tramp-flush-file-property v (file-name-directory localname)) |
592 (tramp-flush-file-property v localname) | 587 (tramp-flush-file-property v localname) |
593 (let ((file (tramp-smb-get-localname localname t)) | 588 (let ((file (tramp-smb-get-localname localname t)) |
594 (curbuf (current-buffer)) | 589 (curbuf (current-buffer)) |
595 tmpfil) | 590 (tmpfile (tramp-make-temp-file filename))) |
596 ;; Write region into a tmp file. | |
597 (setq tmpfil (tramp-make-temp-file filename)) | |
598 ;; We say `no-message' here because we don't want the visited file | 591 ;; We say `no-message' here because we don't want the visited file |
599 ;; modtime data to be clobbered from the temp file. We call | 592 ;; modtime data to be clobbered from the temp file. We call |
600 ;; `set-visited-file-modtime' ourselves later on. | 593 ;; `set-visited-file-modtime' ourselves later on. |
601 (tramp-run-real-handler | 594 (tramp-run-real-handler |
602 'write-region | 595 'write-region |
603 (if confirm ; don't pass this arg unless defined for backward compat. | 596 (if confirm ; don't pass this arg unless defined for backward compat. |
604 (list start end tmpfil append 'no-message lockname confirm) | 597 (list start end tmpfile append 'no-message lockname confirm) |
605 (list start end tmpfil append 'no-message lockname))) | 598 (list start end tmpfile append 'no-message lockname))) |
606 | 599 |
607 (tramp-message v 5 "Writing tmp file %s to file %s..." tmpfil filename) | 600 (tramp-message v 5 "Writing tmp file %s to file %s..." tmpfile filename) |
608 (if (tramp-smb-send-command v (format "put %s \"%s\"" tmpfil file)) | 601 (if (tramp-smb-send-command v (format "put %s \"%s\"" tmpfile file)) |
609 (tramp-message | 602 (tramp-message |
610 v 5 "Writing tmp file %s to file %s...done" tmpfil filename) | 603 v 5 "Writing tmp file %s to file %s...done" tmpfile filename) |
611 (tramp-error v 'file-error "Cannot write `%s'" filename)) | 604 (tramp-error v 'file-error "Cannot write `%s'" filename)) |
612 | 605 |
613 (delete-file tmpfil) | 606 (delete-file tmpfile) |
614 (unless (equal curbuf (current-buffer)) | 607 (unless (equal curbuf (current-buffer)) |
615 (tramp-error | 608 (tramp-error |
616 v 'file-error | 609 v 'file-error |
617 "Buffer has changed from `%s' to `%s'" curbuf (current-buffer))) | 610 "Buffer has changed from `%s' to `%s'" curbuf (current-buffer))) |
618 (when (eq visit t) | 611 (when (eq visit t) |