aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog28
-rw-r--r--lisp/net/tramp-gvfs.el5
-rw-r--r--lisp/net/tramp-sh.el646
-rw-r--r--lisp/net/tramp-smb.el4
-rw-r--r--lisp/net/tramp.el566
5 files changed, 633 insertions, 616 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 21c50dbc54d..5f0a0866962 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,31 @@
12010-10-04 Michael Albinus <michael.albinus@gmx.de>
2
3 Continue reorganization of load dependencies. (Bug#7156)
4
5 * net/tramp.el (tramp-handle-file-local-copy-hook)
6 (tramp-delete-temp-file-function): Move down.
7 (tramp-exists-file-name-handler): Move up.
8 (tramp-register-file-name-handlers): Simplify autoload.
9 (tramp-handle-write-region-hook, tramp-handle-directory-file-name)
10 (tramp-handle-directory-files, tramp-handle-dired-uncache)
11 (tramp-handle-file-modes, tramp-handle-file-name-as-directory)
12 (tramp-handle-file-name-completion)
13 (tramp-handle-file-name-directory)
14 (tramp-handle-file-name-nondirectory, tramp-handle-file-regular-p)
15 (tramp-handle-file-remote-p, tramp-handle-file-symlink-p)
16 (tramp-handle-find-backup-file-name)
17 (tramp-handle-insert-file-contents, tramp-handle-load)
18 (tramp-handle-substitute-in-file-name)
19 (tramp-handle-unhandled-file-name-directory)
20 (tramp-mode-string-to-int, tramp-local-host-p)
21 (tramp-make-tramp-temp-file): Moved from tramp-sh.el.
22
23 * net/tramp-gvfs.el (top):
24 * net/tramp-smb.el (top): Do not require 'tramp-sh.
25
26 * net/tramp-sh.el (all): Move several objects to tramp.el, see
27 there. Rename `tramp-handle-*' to `tramp-sh-handle-*'.
28
12010-10-04 Glenn Morris <rgm@gnu.org> 292010-10-04 Glenn Morris <rgm@gnu.org>
2 30
3 * calendar/appt.el (appt-add): Ensure reminders are enabled. 31 * calendar/appt.el (appt-add): Ensure reminders are enabled.
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index 151e03e88ab..0d9bd36cc05 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -104,10 +104,6 @@
104 104
105(require 'tramp) 105(require 'tramp)
106 106
107;; We call several `tramp-handle-*' functions directly. So we must
108;; reqire that package as well.
109(require 'tramp-sh)
110
111(require 'dbus) 107(require 'dbus)
112(require 'url-parse) 108(require 'url-parse)
113(require 'url-util) 109(require 'url-util)
@@ -405,6 +401,7 @@ Every entry is a list (NAME ADDRESS).")
405 (file-name-directory . tramp-handle-file-name-directory) 401 (file-name-directory . tramp-handle-file-name-directory)
406 (file-name-nondirectory . tramp-handle-file-name-nondirectory) 402 (file-name-nondirectory . tramp-handle-file-name-nondirectory)
407 ;; `file-name-sans-versions' performed by default handler. 403 ;; `file-name-sans-versions' performed by default handler.
404 ;; CCC: Must be checked!
408 (file-newer-than-file-p . tramp-handle-file-newer-than-file-p) 405 (file-newer-than-file-p . tramp-handle-file-newer-than-file-p)
409 (file-ownership-preserved-p . ignore) 406 (file-ownership-preserved-p . ignore)
410 (file-readable-p . tramp-gvfs-handle-file-readable-p) 407 (file-readable-p . tramp-gvfs-handle-file-readable-p)
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index e31e2e23745..2d1ea436240 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -620,7 +620,7 @@ passed to `format', so percent characters need to be doubled.")
620;; unless this spits out a complete line, including the '\n' at the 620;; unless this spits out a complete line, including the '\n' at the
621;; end. 621;; end.
622;; The device number is returned as "-1", because there will be a virtual 622;; The device number is returned as "-1", because there will be a virtual
623;; device number set in `tramp-handle-file-attributes'. 623;; device number set in `tramp-sh-handle-file-attributes'.
624(defconst tramp-perl-file-attributes 624(defconst tramp-perl-file-attributes
625 "%s -e ' 625 "%s -e '
626@stat = lstat($ARGV[0]); 626@stat = lstat($ARGV[0]);
@@ -867,62 +867,63 @@ This is used to map a mode number to a permission string.")
867;; get-file-buffer. 867;; get-file-buffer.
868(defconst tramp-sh-file-name-handler-alist 868(defconst tramp-sh-file-name-handler-alist
869 '((load . tramp-handle-load) 869 '((load . tramp-handle-load)
870 (make-symbolic-link . tramp-handle-make-symbolic-link) 870 (make-symbolic-link . tramp-sh-handle-make-symbolic-link)
871 (file-name-as-directory . tramp-handle-file-name-as-directory) 871 (file-name-as-directory . tramp-handle-file-name-as-directory)
872 (file-name-directory . tramp-handle-file-name-directory) 872 (file-name-directory . tramp-handle-file-name-directory)
873 (file-name-nondirectory . tramp-handle-file-name-nondirectory) 873 (file-name-nondirectory . tramp-handle-file-name-nondirectory)
874 (file-truename . tramp-handle-file-truename) 874 (file-truename . tramp-sh-handle-file-truename)
875 (file-exists-p . tramp-handle-file-exists-p) 875 (file-exists-p . tramp-sh-handle-file-exists-p)
876 (file-directory-p . tramp-handle-file-directory-p) 876 (file-directory-p . tramp-sh-handle-file-directory-p)
877 (file-executable-p . tramp-handle-file-executable-p) 877 (file-executable-p . tramp-sh-handle-file-executable-p)
878 (file-readable-p . tramp-handle-file-readable-p) 878 (file-readable-p . tramp-sh-handle-file-readable-p)
879 (file-regular-p . tramp-handle-file-regular-p) 879 (file-regular-p . tramp-handle-file-regular-p)
880 (file-symlink-p . tramp-handle-file-symlink-p) 880 (file-symlink-p . tramp-handle-file-symlink-p)
881 (file-writable-p . tramp-handle-file-writable-p) 881 (file-writable-p . tramp-sh-handle-file-writable-p)
882 (file-ownership-preserved-p . tramp-handle-file-ownership-preserved-p) 882 (file-ownership-preserved-p . tramp-sh-handle-file-ownership-preserved-p)
883 (file-newer-than-file-p . tramp-handle-file-newer-than-file-p) 883 (file-newer-than-file-p . tramp-sh-handle-file-newer-than-file-p)
884 (file-attributes . tramp-handle-file-attributes) 884 (file-attributes . tramp-sh-handle-file-attributes)
885 (file-modes . tramp-handle-file-modes) 885 (file-modes . tramp-handle-file-modes)
886 (directory-files . tramp-handle-directory-files) 886 (directory-files . tramp-handle-directory-files)
887 (directory-files-and-attributes . tramp-handle-directory-files-and-attributes) 887 (directory-files-and-attributes
888 (file-name-all-completions . tramp-handle-file-name-all-completions) 888 . tramp-sh-handle-directory-files-and-attributes)
889 (file-name-all-completions . tramp-sh-handle-file-name-all-completions)
889 (file-name-completion . tramp-handle-file-name-completion) 890 (file-name-completion . tramp-handle-file-name-completion)
890 (add-name-to-file . tramp-handle-add-name-to-file) 891 (add-name-to-file . tramp-sh-handle-add-name-to-file)
891 (copy-file . tramp-handle-copy-file) 892 (copy-file . tramp-sh-handle-copy-file)
892 (copy-directory . tramp-handle-copy-directory) 893 (copy-directory . tramp-sh-handle-copy-directory)
893 (rename-file . tramp-handle-rename-file) 894 (rename-file . tramp-sh-handle-rename-file)
894 (set-file-modes . tramp-handle-set-file-modes) 895 (set-file-modes . tramp-sh-handle-set-file-modes)
895 (set-file-times . tramp-handle-set-file-times) 896 (set-file-times . tramp-sh-handle-set-file-times)
896 (make-directory . tramp-handle-make-directory) 897 (make-directory . tramp-sh-handle-make-directory)
897 (delete-directory . tramp-handle-delete-directory) 898 (delete-directory . tramp-sh-handle-delete-directory)
898 (delete-file . tramp-handle-delete-file) 899 (delete-file . tramp-sh-handle-delete-file)
899 (directory-file-name . tramp-handle-directory-file-name) 900 (directory-file-name . tramp-handle-directory-file-name)
900 ;; `executable-find' is not official yet. 901 ;; `executable-find' is not official yet.
901 (executable-find . tramp-handle-executable-find) 902 (executable-find . tramp-sh-handle-executable-find)
902 (start-file-process . tramp-handle-start-file-process) 903 (start-file-process . tramp-sh-handle-start-file-process)
903 (process-file . tramp-handle-process-file) 904 (process-file . tramp-sh-handle-process-file)
904 (shell-command . tramp-handle-shell-command) 905 (shell-command . tramp-sh-handle-shell-command)
905 (insert-directory . tramp-handle-insert-directory) 906 (insert-directory . tramp-sh-handle-insert-directory)
906 (expand-file-name . tramp-handle-expand-file-name) 907 (expand-file-name . tramp-sh-handle-expand-file-name)
907 (substitute-in-file-name . tramp-handle-substitute-in-file-name) 908 (substitute-in-file-name . tramp-handle-substitute-in-file-name)
908 (file-local-copy . tramp-handle-file-local-copy) 909 (file-local-copy . tramp-sh-handle-file-local-copy)
909 (file-remote-p . tramp-handle-file-remote-p) 910 (file-remote-p . tramp-handle-file-remote-p)
910 (insert-file-contents . tramp-handle-insert-file-contents) 911 (insert-file-contents . tramp-handle-insert-file-contents)
911 (insert-file-contents-literally 912 (insert-file-contents-literally
912 . tramp-handle-insert-file-contents-literally) 913 . tramp-sh-handle-insert-file-contents-literally)
913 (write-region . tramp-handle-write-region) 914 (write-region . tramp-sh-handle-write-region)
914 (find-backup-file-name . tramp-handle-find-backup-file-name) 915 (find-backup-file-name . tramp-sh-handle-find-backup-file-name)
915 (make-auto-save-file-name . tramp-handle-make-auto-save-file-name) 916 (make-auto-save-file-name . tramp-sh-handle-make-auto-save-file-name)
916 (unhandled-file-name-directory . tramp-handle-unhandled-file-name-directory) 917 (unhandled-file-name-directory . tramp-handle-unhandled-file-name-directory)
917 (dired-compress-file . tramp-handle-dired-compress-file) 918 (dired-compress-file . tramp-sh-handle-dired-compress-file)
918 (dired-recursive-delete-directory 919 (dired-recursive-delete-directory
919 . tramp-handle-dired-recursive-delete-directory) 920 . tramp-sh-handle-dired-recursive-delete-directory)
920 (dired-uncache . tramp-handle-dired-uncache) 921 (dired-uncache . tramp-handle-dired-uncache)
921 (set-visited-file-modtime . tramp-handle-set-visited-file-modtime) 922 (set-visited-file-modtime . tramp-sh-handle-set-visited-file-modtime)
922 (verify-visited-file-modtime . tramp-handle-verify-visited-file-modtime) 923 (verify-visited-file-modtime . tramp-sh-handle-verify-visited-file-modtime)
923 (file-selinux-context . tramp-handle-file-selinux-context) 924 (file-selinux-context . tramp-sh-handle-file-selinux-context)
924 (set-file-selinux-context . tramp-handle-set-file-selinux-context) 925 (set-file-selinux-context . tramp-sh-handle-set-file-selinux-context)
925 (vc-registered . tramp-handle-vc-registered)) 926 (vc-registered . tramp-sh-handle-vc-registered))
926 "Alist of handler functions. 927 "Alist of handler functions.
927Operations not mentioned here will be handled by the normal Emacs functions.") 928Operations not mentioned here will be handled by the normal Emacs functions.")
928 929
@@ -933,7 +934,7 @@ Operations not mentioned here will be handled by the normal Emacs functions.")
933 934
934;;; File Name Handler Functions: 935;;; File Name Handler Functions:
935 936
936(defun tramp-handle-make-symbolic-link 937(defun tramp-sh-handle-make-symbolic-link
937 (filename linkname &optional ok-if-already-exists) 938 (filename linkname &optional ok-if-already-exists)
938 "Like `make-symbolic-link' for Tramp files. 939 "Like `make-symbolic-link' for Tramp files.
939If LINKNAME is a non-Tramp file, it is used verbatim as the target of 940If LINKNAME is a non-Tramp file, it is used verbatim as the target of
@@ -988,71 +989,7 @@ target of the symlink differ."
988 (tramp-shell-quote-argument l-localname)) 989 (tramp-shell-quote-argument l-localname))
989 t)))) 990 t))))
990 991
991(defun tramp-handle-load (file &optional noerror nomessage nosuffix must-suffix) 992(defun tramp-sh-handle-file-truename (filename &optional counter prev-dirs)
992 "Like `load' for Tramp files."
993 (with-parsed-tramp-file-name (expand-file-name file) nil
994 (unless nosuffix
995 (cond ((file-exists-p (concat file ".elc"))
996 (setq file (concat file ".elc")))
997 ((file-exists-p (concat file ".el"))
998 (setq file (concat file ".el")))))
999 (when must-suffix
1000 ;; The first condition is always true for absolute file names.
1001 ;; Included for safety's sake.
1002 (unless (or (file-name-directory file)
1003 (string-match "\\.elc?\\'" file))
1004 (tramp-error
1005 v 'file-error
1006 "File `%s' does not include a `.el' or `.elc' suffix" file)))
1007 (unless noerror
1008 (when (not (file-exists-p file))
1009 (tramp-error v 'file-error "Cannot load nonexistent file `%s'" file)))
1010 (if (not (file-exists-p file))
1011 nil
1012 (let ((tramp-message-show-message (not nomessage)))
1013 (with-progress-reporter v 0 (format "Loading %s" file)
1014 (let ((local-copy (file-local-copy file)))
1015 ;; MUST-SUFFIX doesn't exist on XEmacs, so let it default to nil.
1016 (unwind-protect
1017 (load local-copy noerror t t)
1018 (delete-file local-copy)))))
1019 t)))
1020
1021;; Localname manipulation functions that grok Tramp localnames...
1022(defun tramp-handle-file-name-as-directory (file)
1023 "Like `file-name-as-directory' but aware of Tramp files."
1024 ;; `file-name-as-directory' would be sufficient except localname is
1025 ;; the empty string.
1026 (let ((v (tramp-dissect-file-name file t)))
1027 ;; Run the command on the localname portion only.
1028 (tramp-make-tramp-file-name
1029 (tramp-file-name-method v)
1030 (tramp-file-name-user v)
1031 (tramp-file-name-host v)
1032 (tramp-run-real-handler
1033 'file-name-as-directory (list (or (tramp-file-name-localname v) ""))))))
1034
1035(defun tramp-handle-file-name-directory (file)
1036 "Like `file-name-directory' but aware of Tramp files."
1037 ;; Everything except the last filename thing is the directory. We
1038 ;; cannot apply `with-parsed-tramp-file-name', because this expands
1039 ;; the remote file name parts. This is a problem when we are in
1040 ;; file name completion.
1041 (let ((v (tramp-dissect-file-name file t)))
1042 ;; Run the command on the localname portion only.
1043 (tramp-make-tramp-file-name
1044 (tramp-file-name-method v)
1045 (tramp-file-name-user v)
1046 (tramp-file-name-host v)
1047 (tramp-run-real-handler
1048 'file-name-directory (list (or (tramp-file-name-localname v) ""))))))
1049
1050(defun tramp-handle-file-name-nondirectory (file)
1051 "Like `file-name-nondirectory' but aware of Tramp files."
1052 (with-parsed-tramp-file-name file nil
1053 (tramp-run-real-handler 'file-name-nondirectory (list localname))))
1054
1055(defun tramp-handle-file-truename (filename &optional counter prev-dirs)
1056 "Like `file-truename' for Tramp files." 993 "Like `file-truename' for Tramp files."
1057 (with-parsed-tramp-file-name (expand-file-name filename) nil 994 (with-parsed-tramp-file-name (expand-file-name filename) nil
1058 (with-file-property v localname "file-truename" 995 (with-file-property v localname "file-truename"
@@ -1158,7 +1095,7 @@ target of the symlink differ."
1158 1095
1159;; Basic functions. 1096;; Basic functions.
1160 1097
1161(defun tramp-handle-file-exists-p (filename) 1098(defun tramp-sh-handle-file-exists-p (filename)
1162 "Like `file-exists-p' for Tramp files." 1099 "Like `file-exists-p' for Tramp files."
1163 (with-parsed-tramp-file-name filename nil 1100 (with-parsed-tramp-file-name filename nil
1164 (with-file-property v localname "file-exists-p" 1101 (with-file-property v localname "file-exists-p"
@@ -1176,7 +1113,7 @@ target of the symlink differ."
1176;; CCC: This should check for an error condition and signal failure 1113;; CCC: This should check for an error condition and signal failure
1177;; when something goes wrong. 1114;; when something goes wrong.
1178;; Daniel Pittman <daniel@danann.net> 1115;; Daniel Pittman <daniel@danann.net>
1179(defun tramp-handle-file-attributes (filename &optional id-format) 1116(defun tramp-sh-handle-file-attributes (filename &optional id-format)
1180 "Like `file-attributes' for Tramp files." 1117 "Like `file-attributes' for Tramp files."
1181 (unless id-format (setq id-format 'integer)) 1118 (unless id-format (setq id-format 'integer))
1182 ;; Don't modify `last-coding-system-used' by accident. 1119 ;; Don't modify `last-coding-system-used' by accident.
@@ -1314,7 +1251,7 @@ target of the symlink differ."
1314 (if (eq id-format 'integer) "%g" "\"%G\"") 1251 (if (eq id-format 'integer) "%g" "\"%G\"")
1315 (tramp-shell-quote-argument localname)))) 1252 (tramp-shell-quote-argument localname))))
1316 1253
1317(defun tramp-handle-set-visited-file-modtime (&optional time-list) 1254(defun tramp-sh-handle-set-visited-file-modtime (&optional time-list)
1318 "Like `set-visited-file-modtime' for Tramp files." 1255 "Like `set-visited-file-modtime' for Tramp files."
1319 (unless (buffer-file-name) 1256 (unless (buffer-file-name)
1320 (error "Can't set-visited-file-modtime: buffer `%s' not visiting a file" 1257 (error "Can't set-visited-file-modtime: buffer `%s' not visiting a file"
@@ -1348,8 +1285,8 @@ target of the symlink differ."
1348 nil))))) 1285 nil)))))
1349 1286
1350;; This function makes the same assumption as 1287;; This function makes the same assumption as
1351;; `tramp-handle-set-visited-file-modtime'. 1288;; `tramp-sh-handle-set-visited-file-modtime'.
1352(defun tramp-handle-verify-visited-file-modtime (buf) 1289(defun tramp-sh-handle-verify-visited-file-modtime (buf)
1353 "Like `verify-visited-file-modtime' for Tramp files. 1290 "Like `verify-visited-file-modtime' for Tramp files.
1354At the time `verify-visited-file-modtime' calls this function, we 1291At the time `verify-visited-file-modtime' calls this function, we
1355already know that the buffer is visiting a file and that 1292already know that the buffer is visiting a file and that
@@ -1401,7 +1338,7 @@ of."
1401 ;; only if that agrees with the buffer's record. 1338 ;; only if that agrees with the buffer's record.
1402 (t (equal mt '(-1 65535)))))))))) 1339 (t (equal mt '(-1 65535))))))))))
1403 1340
1404(defun tramp-handle-set-file-modes (filename mode) 1341(defun tramp-sh-handle-set-file-modes (filename mode)
1405 "Like `set-file-modes' for Tramp files." 1342 "Like `set-file-modes' for Tramp files."
1406 (with-parsed-tramp-file-name filename nil 1343 (with-parsed-tramp-file-name filename nil
1407 (tramp-flush-file-property v localname) 1344 (tramp-flush-file-property v localname)
@@ -1413,7 +1350,7 @@ of."
1413 (tramp-shell-quote-argument localname)) 1350 (tramp-shell-quote-argument localname))
1414 "Error while changing file's mode %s" filename))) 1351 "Error while changing file's mode %s" filename)))
1415 1352
1416(defun tramp-handle-set-file-times (filename &optional time) 1353(defun tramp-sh-handle-set-file-times (filename &optional time)
1417 "Like `set-file-times' for Tramp files." 1354 "Like `set-file-times' for Tramp files."
1418 (if (file-remote-p filename) 1355 (if (file-remote-p filename)
1419 (with-parsed-tramp-file-name filename nil 1356 (with-parsed-tramp-file-name filename nil
@@ -1486,7 +1423,7 @@ and gid of the corresponding user is taken. Both parameters must be integers."
1486 vec (format "echo \\\"`%S`\\\"" result)) 1423 vec (format "echo \\\"`%S`\\\"" result))
1487 "Enforcing"))))) 1424 "Enforcing")))))
1488 1425
1489(defun tramp-handle-file-selinux-context (filename) 1426(defun tramp-sh-handle-file-selinux-context (filename)
1490 "Like `file-selinux-context' for Tramp files." 1427 "Like `file-selinux-context' for Tramp files."
1491 (with-parsed-tramp-file-name filename nil 1428 (with-parsed-tramp-file-name filename nil
1492 (with-file-property v localname "file-selinux-context" 1429 (with-file-property v localname "file-selinux-context"
@@ -1507,7 +1444,7 @@ and gid of the corresponding user is taken. Both parameters must be integers."
1507 ;; Return the context. 1444 ;; Return the context.
1508 context)))) 1445 context))))
1509 1446
1510(defun tramp-handle-set-file-selinux-context (filename context) 1447(defun tramp-sh-handle-set-file-selinux-context (filename context)
1511 "Like `set-file-selinux-context' for Tramp files." 1448 "Like `set-file-selinux-context' for Tramp files."
1512 (with-parsed-tramp-file-name filename nil 1449 (with-parsed-tramp-file-name filename nil
1513 (if (and (consp context) 1450 (if (and (consp context)
@@ -1530,7 +1467,7 @@ and gid of the corresponding user is taken. Both parameters must be integers."
1530 1467
1531;; Simple functions using the `test' command. 1468;; Simple functions using the `test' command.
1532 1469
1533(defun tramp-handle-file-executable-p (filename) 1470(defun tramp-sh-handle-file-executable-p (filename)
1534 "Like `file-executable-p' for Tramp files." 1471 "Like `file-executable-p' for Tramp files."
1535 (with-parsed-tramp-file-name filename nil 1472 (with-parsed-tramp-file-name filename nil
1536 (with-file-property v localname "file-executable-p" 1473 (with-file-property v localname "file-executable-p"
@@ -1539,7 +1476,7 @@ and gid of the corresponding user is taken. Both parameters must be integers."
1539 (or (tramp-check-cached-permissions v ?x) 1476 (or (tramp-check-cached-permissions v ?x)
1540 (tramp-run-test "-x" filename))))) 1477 (tramp-run-test "-x" filename)))))
1541 1478
1542(defun tramp-handle-file-readable-p (filename) 1479(defun tramp-sh-handle-file-readable-p (filename)
1543 "Like `file-readable-p' for Tramp files." 1480 "Like `file-readable-p' for Tramp files."
1544 (with-parsed-tramp-file-name filename nil 1481 (with-parsed-tramp-file-name filename nil
1545 (with-file-property v localname "file-readable-p" 1482 (with-file-property v localname "file-readable-p"
@@ -1553,7 +1490,7 @@ and gid of the corresponding user is taken. Both parameters must be integers."
1553;; expansion will also provide a `test' command which groks `-nt' (for 1490;; expansion will also provide a `test' command which groks `-nt' (for
1554;; newer than). If this breaks, tell me about it and I'll try to do 1491;; newer than). If this breaks, tell me about it and I'll try to do
1555;; something smarter about it. 1492;; something smarter about it.
1556(defun tramp-handle-file-newer-than-file-p (file1 file2) 1493(defun tramp-sh-handle-file-newer-than-file-p (file1 file2)
1557 "Like `file-newer-than-file-p' for Tramp files." 1494 "Like `file-newer-than-file-p' for Tramp files."
1558 (cond ((not (file-exists-p file1)) 1495 (cond ((not (file-exists-p file1))
1559 nil) 1496 nil)
@@ -1588,13 +1525,7 @@ and gid of the corresponding user is taken. Both parameters must be integers."
1588 1525
1589;; Functions implemented using the basic functions above. 1526;; Functions implemented using the basic functions above.
1590 1527
1591(defun tramp-handle-file-modes (filename) 1528(defun tramp-sh-handle-file-directory-p (filename)
1592 "Like `file-modes' for Tramp files."
1593 (let ((truename (or (file-truename filename) filename)))
1594 (when (file-exists-p truename)
1595 (tramp-mode-string-to-int (nth 8 (file-attributes truename))))))
1596
1597(defun tramp-handle-file-directory-p (filename)
1598 "Like `file-directory-p' for Tramp files." 1529 "Like `file-directory-p' for Tramp files."
1599 ;; Care must be taken that this function returns `t' for symlinks 1530 ;; Care must be taken that this function returns `t' for symlinks
1600 ;; pointing to directories. Surely the most obvious implementation 1531 ;; pointing to directories. Surely the most obvious implementation
@@ -1608,23 +1539,7 @@ and gid of the corresponding user is taken. Both parameters must be integers."
1608 (with-file-property v localname "file-directory-p" 1539 (with-file-property v localname "file-directory-p"
1609 (tramp-run-test "-d" filename)))) 1540 (tramp-run-test "-d" filename))))
1610 1541
1611(defun tramp-handle-file-regular-p (filename) 1542(defun tramp-sh-handle-file-writable-p (filename)
1612 "Like `file-regular-p' for Tramp files."
1613 (and (file-exists-p filename)
1614 (eq ?- (aref (nth 8 (file-attributes filename)) 0))))
1615
1616(defun tramp-handle-file-symlink-p (filename)
1617 "Like `file-symlink-p' for Tramp files."
1618 (with-parsed-tramp-file-name filename nil
1619 (let ((x (car (file-attributes filename))))
1620 (when (stringp x)
1621 ;; When Tramp is running on VMS, then `file-name-absolute-p'
1622 ;; might do weird things.
1623 (if (file-name-absolute-p x)
1624 (tramp-make-tramp-file-name method user host x)
1625 x)))))
1626
1627(defun tramp-handle-file-writable-p (filename)
1628 "Like `file-writable-p' for Tramp files." 1543 "Like `file-writable-p' for Tramp files."
1629 (with-parsed-tramp-file-name filename nil 1544 (with-parsed-tramp-file-name filename nil
1630 (with-file-property v localname "file-writable-p" 1545 (with-file-property v localname "file-writable-p"
@@ -1637,7 +1552,7 @@ and gid of the corresponding user is taken. Both parameters must be integers."
1637 (and (tramp-run-test "-d" (file-name-directory filename)) 1552 (and (tramp-run-test "-d" (file-name-directory filename))
1638 (tramp-run-test "-w" (file-name-directory filename))))))) 1553 (tramp-run-test "-w" (file-name-directory filename)))))))
1639 1554
1640(defun tramp-handle-file-ownership-preserved-p (filename) 1555(defun tramp-sh-handle-file-ownership-preserved-p (filename)
1641 "Like `file-ownership-preserved-p' for Tramp files." 1556 "Like `file-ownership-preserved-p' for Tramp files."
1642 (with-parsed-tramp-file-name filename nil 1557 (with-parsed-tramp-file-name filename nil
1643 (with-file-property v localname "file-ownership-preserved-p" 1558 (with-file-property v localname "file-ownership-preserved-p"
@@ -1647,45 +1562,9 @@ and gid of the corresponding user is taken. Both parameters must be integers."
1647 (or (null attributes) 1562 (or (null attributes)
1648 (= (nth 2 attributes) (tramp-get-remote-uid v 'integer))))))) 1563 (= (nth 2 attributes) (tramp-get-remote-uid v 'integer)))))))
1649 1564
1650;; Other file name ops.
1651
1652(defun tramp-handle-directory-file-name (directory)
1653 "Like `directory-file-name' for Tramp files."
1654 ;; If localname component of filename is "/", leave it unchanged.
1655 ;; Otherwise, remove any trailing slash from localname component.
1656 ;; Method, host, etc, are unchanged. Does it make sense to try
1657 ;; to avoid parsing the filename?
1658 (with-parsed-tramp-file-name directory nil
1659 (if (and (not (zerop (length localname)))
1660 (eq (aref localname (1- (length localname))) ?/)
1661 (not (string= localname "/")))
1662 (substring directory 0 -1)
1663 directory)))
1664
1665;; Directory listings. 1565;; Directory listings.
1666 1566
1667(defun tramp-handle-directory-files 1567(defun tramp-sh-handle-directory-files-and-attributes
1668 (directory &optional full match nosort files-only)
1669 "Like `directory-files' for Tramp files."
1670 ;; FILES-ONLY is valid for XEmacs only.
1671 (when (file-directory-p directory)
1672 (setq directory (file-name-as-directory (expand-file-name directory)))
1673 (let ((temp (nreverse (file-name-all-completions "" directory)))
1674 result item)
1675
1676 (while temp
1677 (setq item (directory-file-name (pop temp)))
1678 (when (and (or (null match) (string-match match item))
1679 (or (null files-only)
1680 ;; Files only.
1681 (and (equal files-only t) (file-regular-p item))
1682 ;; Directories only.
1683 (file-directory-p item)))
1684 (push (if full (concat directory item) item)
1685 result)))
1686 (if nosort result (sort result 'string<)))))
1687
1688(defun tramp-handle-directory-files-and-attributes
1689 (directory &optional full match nosort id-format) 1568 (directory &optional full match nosort id-format)
1690 "Like `directory-files-and-attributes' for Tramp files." 1569 "Like `directory-files-and-attributes' for Tramp files."
1691 (unless id-format (setq id-format 'integer)) 1570 (unless id-format (setq id-format 'integer))
@@ -1760,7 +1639,7 @@ and gid of the corresponding user is taken. Both parameters must be integers."
1760 1639
1761;; This function should return "foo/" for directories and "bar" for 1640;; This function should return "foo/" for directories and "bar" for
1762;; files. 1641;; files.
1763(defun tramp-handle-file-name-all-completions (filename directory) 1642(defun tramp-sh-handle-file-name-all-completions (filename directory)
1764 "Like `file-name-all-completions' for Tramp files." 1643 "Like `file-name-all-completions' for Tramp files."
1765 (unless (save-match-data (string-match "/" filename)) 1644 (unless (save-match-data (string-match "/" filename))
1766 (with-parsed-tramp-file-name (expand-file-name directory) nil 1645 (with-parsed-tramp-file-name (expand-file-name directory) nil
@@ -1866,7 +1745,7 @@ and gid of the corresponding user is taken. Both parameters must be integers."
1866 (forward-line -1) 1745 (forward-line -1)
1867 (tramp-error 1746 (tramp-error
1868 v 'file-error 1747 v 'file-error
1869 "tramp-handle-file-name-all-completions: %s" 1748 "tramp-sh-handle-file-name-all-completions: %s"
1870 (buffer-substring 1749 (buffer-substring
1871 (point) (tramp-compat-line-end-position)))) 1750 (point) (tramp-compat-line-end-position))))
1872 ;; For peace of mind, if buffer doesn't end in `fail' 1751 ;; For peace of mind, if buffer doesn't end in `fail'
@@ -1877,7 +1756,7 @@ and gid of the corresponding user is taken. Both parameters must be integers."
1877 (tramp-error 1756 (tramp-error
1878 v 'file-error 1757 v 'file-error
1879 "\ 1758 "\
1880tramp-handle-file-name-all-completions: internal error accessing `%s': `%s'" 1759tramp-sh-handle-file-name-all-completions: internal error accessing `%s': `%s'"
1881 (tramp-shell-quote-argument localname) (buffer-string)))) 1760 (tramp-shell-quote-argument localname) (buffer-string))))
1882 1761
1883 (while (zerop (forward-line -1)) 1762 (while (zerop (forward-line -1))
@@ -1903,22 +1782,9 @@ tramp-handle-file-name-all-completions: internal error accessing `%s': `%s'"
1903 "file-name-all-completions" 1782 "file-name-all-completions"
1904 result)))))))) 1783 result))))))))
1905 1784
1906(defun tramp-handle-file-name-completion
1907 (filename directory &optional predicate)
1908 "Like `file-name-completion' for Tramp files."
1909 (unless (tramp-tramp-file-p directory)
1910 (error
1911 "tramp-handle-file-name-completion invoked on non-tramp directory `%s'"
1912 directory))
1913 (try-completion
1914 filename
1915 (mapcar 'list (file-name-all-completions filename directory))
1916 (when predicate
1917 (lambda (x) (funcall predicate (expand-file-name (car x) directory))))))
1918
1919;; cp, mv and ln 1785;; cp, mv and ln
1920 1786
1921(defun tramp-handle-add-name-to-file 1787(defun tramp-sh-handle-add-name-to-file
1922 (filename newname &optional ok-if-already-exists) 1788 (filename newname &optional ok-if-already-exists)
1923 "Like `add-name-to-file' for Tramp files." 1789 "Like `add-name-to-file' for Tramp files."
1924 (unless (tramp-equal-remote filename newname) 1790 (unless (tramp-equal-remote filename newname)
@@ -1950,7 +1816,7 @@ tramp-handle-file-name-all-completions: internal error accessing `%s': `%s'"
1950 "error with add-name-to-file, see buffer `%s' for details" 1816 "error with add-name-to-file, see buffer `%s' for details"
1951 (buffer-name)))))) 1817 (buffer-name))))))
1952 1818
1953(defun tramp-handle-copy-file 1819(defun tramp-sh-handle-copy-file
1954 (filename newname &optional ok-if-already-exists keep-date 1820 (filename newname &optional ok-if-already-exists keep-date
1955 preserve-uid-gid preserve-selinux-context) 1821 preserve-uid-gid preserve-selinux-context)
1956 "Like `copy-file' for Tramp files." 1822 "Like `copy-file' for Tramp files."
@@ -1977,7 +1843,8 @@ tramp-handle-file-name-all-completions: internal error accessing `%s': `%s'"
1977 (tramp-run-real-handler 1843 (tramp-run-real-handler
1978 'copy-file (list filename newname ok-if-already-exists keep-date))))) 1844 'copy-file (list filename newname ok-if-already-exists keep-date)))))
1979 1845
1980(defun tramp-handle-copy-directory (dirname newname &optional keep-date parents) 1846(defun tramp-sh-handle-copy-directory
1847 (dirname newname &optional keep-date parents)
1981 "Like `copy-directory' for Tramp files." 1848 "Like `copy-directory' for Tramp files."
1982 (let ((t1 (tramp-tramp-file-p dirname)) 1849 (let ((t1 (tramp-tramp-file-p dirname))
1983 (t2 (tramp-tramp-file-p newname))) 1850 (t2 (tramp-tramp-file-p newname)))
@@ -2013,7 +1880,7 @@ tramp-handle-file-name-all-completions: internal error accessing `%s': `%s'"
2013 (tramp-flush-file-property v (file-name-directory localname)) 1880 (tramp-flush-file-property v (file-name-directory localname))
2014 (tramp-flush-file-property v localname)))))) 1881 (tramp-flush-file-property v localname))))))
2015 1882
2016(defun tramp-handle-rename-file 1883(defun tramp-sh-handle-rename-file
2017 (filename newname &optional ok-if-already-exists) 1884 (filename newname &optional ok-if-already-exists)
2018 "Like `rename-file' for Tramp files." 1885 "Like `rename-file' for Tramp files."
2019 ;; Check if both files are local -- invoke normal rename-file. 1886 ;; Check if both files are local -- invoke normal rename-file.
@@ -2041,9 +1908,10 @@ as FILENAME. PRESERVE-UID-GID, when non-nil, instructs to keep
2041the uid and gid if both files are on the same host. 1908the uid and gid if both files are on the same host.
2042PRESERVE-SELINUX-CONTEXT activates selinux commands. 1909PRESERVE-SELINUX-CONTEXT activates selinux commands.
2043 1910
2044This function is invoked by `tramp-handle-copy-file' and 1911This function is invoked by `tramp-sh-handle-copy-file' and
2045`tramp-handle-rename-file'. It is an error if OP is neither of `copy' 1912`tramp-sh-handle-rename-file'. It is an error if OP is neither
2046and `rename'. FILENAME and NEWNAME must be absolute file names." 1913of `copy' and `rename'. FILENAME and NEWNAME must be absolute
1914file names."
2047 (unless (memq op '(copy rename)) 1915 (unless (memq op '(copy rename))
2048 (error "Unknown operation `%s', must be `copy' or `rename'" op)) 1916 (error "Unknown operation `%s', must be `copy' or `rename'" op))
2049 (let ((t1 (tramp-tramp-file-p filename)) 1917 (let ((t1 (tramp-tramp-file-p filename))
@@ -2464,7 +2332,7 @@ The method used must be an out-of-band method."
2464 (delete-file filename) 2332 (delete-file filename)
2465 (tramp-compat-delete-directory filename 'recursive)))))) 2333 (tramp-compat-delete-directory filename 'recursive))))))
2466 2334
2467(defun tramp-handle-make-directory (dir &optional parents) 2335(defun tramp-sh-handle-make-directory (dir &optional parents)
2468 "Like `make-directory' for Tramp files." 2336 "Like `make-directory' for Tramp files."
2469 (setq dir (expand-file-name dir)) 2337 (setq dir (expand-file-name dir))
2470 (with-parsed-tramp-file-name dir nil 2338 (with-parsed-tramp-file-name dir nil
@@ -2476,7 +2344,7 @@ The method used must be an out-of-band method."
2476 (tramp-shell-quote-argument localname)) 2344 (tramp-shell-quote-argument localname))
2477 "Couldn't make directory %s" dir)))) 2345 "Couldn't make directory %s" dir))))
2478 2346
2479(defun tramp-handle-delete-directory (directory &optional recursive) 2347(defun tramp-sh-handle-delete-directory (directory &optional recursive)
2480 "Like `delete-directory' for Tramp files." 2348 "Like `delete-directory' for Tramp files."
2481 (setq directory (expand-file-name directory)) 2349 (setq directory (expand-file-name directory))
2482 (with-parsed-tramp-file-name directory nil 2350 (with-parsed-tramp-file-name directory nil
@@ -2488,7 +2356,7 @@ The method used must be an out-of-band method."
2488 (tramp-shell-quote-argument localname)) 2356 (tramp-shell-quote-argument localname))
2489 "Couldn't delete %s" directory))) 2357 "Couldn't delete %s" directory)))
2490 2358
2491(defun tramp-handle-delete-file (filename &optional trash) 2359(defun tramp-sh-handle-delete-file (filename &optional trash)
2492 "Like `delete-file' for Tramp files." 2360 "Like `delete-file' for Tramp files."
2493 (setq filename (expand-file-name filename)) 2361 (setq filename (expand-file-name filename))
2494 (with-parsed-tramp-file-name filename nil 2362 (with-parsed-tramp-file-name filename nil
@@ -2504,7 +2372,7 @@ The method used must be an out-of-band method."
2504 2372
2505;; CCC: This does not seem to be enough. Something dies when 2373;; CCC: This does not seem to be enough. Something dies when
2506;; we try and delete two directories under Tramp :/ 2374;; we try and delete two directories under Tramp :/
2507(defun tramp-handle-dired-recursive-delete-directory (filename) 2375(defun tramp-sh-handle-dired-recursive-delete-directory (filename)
2508 "Recursively delete the directory given. 2376 "Recursively delete the directory given.
2509This is like `dired-recursive-delete-directory' for Tramp files." 2377This is like `dired-recursive-delete-directory' for Tramp files."
2510 (with-parsed-tramp-file-name filename nil 2378 (with-parsed-tramp-file-name filename nil
@@ -2528,7 +2396,7 @@ This is like `dired-recursive-delete-directory' for Tramp files."
2528 (tramp-error 2396 (tramp-error
2529 v 'file-error "Failed to recursively delete %s" filename)))) 2397 v 'file-error "Failed to recursively delete %s" filename))))
2530 2398
2531(defun tramp-handle-dired-compress-file (file &rest ok-flag) 2399(defun tramp-sh-handle-dired-compress-file (file &rest ok-flag)
2532 "Like `dired-compress-file' for Tramp files." 2400 "Like `dired-compress-file' for Tramp files."
2533 ;; OK-FLAG is valid for XEmacs only, but not implemented. 2401 ;; OK-FLAG is valid for XEmacs only, but not implemented.
2534 ;; Code stolen mainly from dired-aux.el. 2402 ;; Code stolen mainly from dired-aux.el.
@@ -2582,14 +2450,7 @@ This is like `dired-recursive-delete-directory' for Tramp files."
2582 (concat file ".z")) 2450 (concat file ".z"))
2583 (t nil)))))))))) 2451 (t nil))))))))))
2584 2452
2585(defun tramp-handle-dired-uncache (dir &optional dir-p) 2453(defun tramp-sh-handle-insert-directory
2586 "Like `dired-uncache' for Tramp files."
2587 ;; DIR-P is valid for XEmacs only.
2588 (with-parsed-tramp-file-name
2589 (if (or dir-p (file-directory-p dir)) dir (file-name-directory dir)) nil
2590 (tramp-flush-directory-property v localname)))
2591
2592(defun tramp-handle-insert-directory
2593 (filename switches &optional wildcard full-directory-p) 2454 (filename switches &optional wildcard full-directory-p)
2594 "Like `insert-directory' for Tramp files." 2455 "Like `insert-directory' for Tramp files."
2595 (setq filename (expand-file-name filename)) 2456 (setq filename (expand-file-name filename))
@@ -2692,15 +2553,9 @@ This is like `dired-recursive-delete-directory' for Tramp files."
2692 2553
2693 (goto-char (point-max)))))) 2554 (goto-char (point-max))))))
2694 2555
2695(defun tramp-handle-unhandled-file-name-directory (filename)
2696 "Like `unhandled-file-name-directory' for Tramp files."
2697 ;; With Emacs 23, we could simply return `nil'. But we must keep it
2698 ;; for backward compatibility.
2699 (expand-file-name "~/"))
2700
2701;; Canonicalization of file names. 2556;; Canonicalization of file names.
2702 2557
2703(defun tramp-handle-expand-file-name (name &optional dir) 2558(defun tramp-sh-handle-expand-file-name (name &optional dir)
2704 "Like `expand-file-name' for Tramp files. 2559 "Like `expand-file-name' for Tramp files.
2705If the localname part of the given filename starts with \"/../\" then 2560If the localname part of the given filename starts with \"/../\" then
2706the result will be a local, non-Tramp, filename." 2561the result will be a local, non-Tramp, filename."
@@ -2759,41 +2614,9 @@ the result will be a local, non-Tramp, filename."
2759 (tramp-run-real-handler 2614 (tramp-run-real-handler
2760 'expand-file-name (list localname)))))))) 2615 'expand-file-name (list localname))))))))
2761 2616
2762(defun tramp-handle-substitute-in-file-name (filename)
2763 "Like `substitute-in-file-name' for Tramp files.
2764\"//\" and \"/~\" substitute only in the local filename part.
2765If the URL Tramp syntax is chosen, \"//\" as method delimeter and \"/~\" at
2766beginning of local filename are not substituted."
2767 ;; First, we must replace environment variables.
2768 (setq filename (tramp-replace-environment-variables filename))
2769 (with-parsed-tramp-file-name filename nil
2770 (if (equal tramp-syntax 'url)
2771 ;; We need to check localname only. The other parts cannot contain
2772 ;; "//" or "/~".
2773 (if (and (> (length localname) 1)
2774 (or (string-match "//" localname)
2775 (string-match "/~" localname 1)))
2776 (tramp-run-real-handler 'substitute-in-file-name (list filename))
2777 (tramp-make-tramp-file-name
2778 (when method (substitute-in-file-name method))
2779 (when user (substitute-in-file-name user))
2780 (when host (substitute-in-file-name host))
2781 (when localname
2782 (tramp-run-real-handler
2783 'substitute-in-file-name (list localname)))))
2784 ;; Ignore in LOCALNAME everything before "//" or "/~".
2785 (when (and (stringp localname) (string-match ".+?/\\(/\\|~\\)" localname))
2786 (setq filename
2787 (concat (file-remote-p filename)
2788 (replace-match "\\1" nil nil localname)))
2789 ;; "/m:h:~" does not work for completion. We use "/m:h:~/".
2790 (when (string-match "~$" filename)
2791 (setq filename (concat filename "/"))))
2792 (tramp-run-real-handler 'substitute-in-file-name (list filename)))))
2793
2794;;; Remote commands: 2617;;; Remote commands:
2795 2618
2796(defun tramp-handle-executable-find (command) 2619(defun tramp-sh-handle-executable-find (command)
2797 "Like `executable-find' for Tramp files." 2620 "Like `executable-find' for Tramp files."
2798 (with-parsed-tramp-file-name default-directory nil 2621 (with-parsed-tramp-file-name default-directory nil
2799 (tramp-find-executable v command (tramp-get-remote-path v) t))) 2622 (tramp-find-executable v command (tramp-get-remote-path v) t)))
@@ -2809,7 +2632,7 @@ beginning of local filename are not substituted."
2809;; We use BUFFER also as connection buffer during setup. Because of 2632;; We use BUFFER also as connection buffer during setup. Because of
2810;; this, its original contents must be saved, and restored once 2633;; this, its original contents must be saved, and restored once
2811;; connection has been setup. 2634;; connection has been setup.
2812(defun tramp-handle-start-file-process (name buffer program &rest args) 2635(defun tramp-sh-handle-start-file-process (name buffer program &rest args)
2813 "Like `start-file-process' for Tramp files." 2636 "Like `start-file-process' for Tramp files."
2814 (with-parsed-tramp-file-name default-directory nil 2637 (with-parsed-tramp-file-name default-directory nil
2815 (unwind-protect 2638 (unwind-protect
@@ -2868,7 +2691,7 @@ beginning of local filename are not substituted."
2868 (tramp-set-connection-property v "process-name" nil) 2691 (tramp-set-connection-property v "process-name" nil)
2869 (tramp-set-connection-property v "process-buffer" nil)))) 2692 (tramp-set-connection-property v "process-buffer" nil))))
2870 2693
2871(defun tramp-handle-process-file 2694(defun tramp-sh-handle-process-file
2872 (program &optional infile destination display &rest args) 2695 (program &optional infile destination display &rest args)
2873 "Like `process-file' for Tramp files." 2696 "Like `process-file' for Tramp files."
2874 ;; The implementation is not complete yet. 2697 ;; The implementation is not complete yet.
@@ -2981,7 +2804,7 @@ beginning of local filename are not substituted."
2981 (keyboard-quit) 2804 (keyboard-quit)
2982 ret)))) 2805 ret))))
2983 2806
2984(defun tramp-handle-call-process-region 2807(defun tramp-sh-handle-call-process-region
2985 (start end program &optional delete buffer display &rest args) 2808 (start end program &optional delete buffer display &rest args)
2986 "Like `call-process-region' for Tramp files." 2809 "Like `call-process-region' for Tramp files."
2987 (let ((tmpfile (tramp-compat-make-temp-file ""))) 2810 (let ((tmpfile (tramp-compat-make-temp-file "")))
@@ -2991,7 +2814,7 @@ beginning of local filename are not substituted."
2991 (apply 'call-process program tmpfile buffer display args) 2814 (apply 'call-process program tmpfile buffer display args)
2992 (delete-file tmpfile)))) 2815 (delete-file tmpfile))))
2993 2816
2994(defun tramp-handle-shell-command 2817(defun tramp-sh-handle-shell-command
2995 (command &optional output-buffer error-buffer) 2818 (command &optional output-buffer error-buffer)
2996 "Like `shell-command' for Tramp files." 2819 "Like `shell-command' for Tramp files."
2997 (let* ((asynchronous (string-match "[ \t]*&[ \t]*\\'" command)) 2820 (let* ((asynchronous (string-match "[ \t]*&[ \t]*\\'" command))
@@ -3072,9 +2895,8 @@ beginning of local filename are not substituted."
3072 (tramp-compat-funcall 'display-message-or-buffer output-buffer) 2895 (tramp-compat-funcall 'display-message-or-buffer output-buffer)
3073 (pop-to-buffer output-buffer)))))))) 2896 (pop-to-buffer output-buffer))))))))
3074 2897
3075(defun tramp-handle-file-local-copy (filename) 2898(defun tramp-sh-handle-file-local-copy (filename)
3076 "Like `file-local-copy' for Tramp files." 2899 "Like `file-local-copy' for Tramp files."
3077
3078 (with-parsed-tramp-file-name filename nil 2900 (with-parsed-tramp-file-name filename nil
3079 (unless (file-exists-p filename) 2901 (unless (file-exists-p filename)
3080 (tramp-error 2902 (tramp-error
@@ -3153,131 +2975,8 @@ beginning of local filename are not substituted."
3153 (run-hooks 'tramp-handle-file-local-copy-hook) 2975 (run-hooks 'tramp-handle-file-local-copy-hook)
3154 tmpfile))) 2976 tmpfile)))
3155 2977
3156(defun tramp-handle-file-remote-p (filename &optional identification connected)
3157 "Like `file-remote-p' for Tramp files."
3158 (let ((tramp-verbose 3))
3159 (when (tramp-tramp-file-p filename)
3160 (let* ((v (tramp-dissect-file-name filename))
3161 (p (tramp-get-connection-process v))
3162 (c (and p (processp p) (memq (process-status p) '(run open)))))
3163 ;; We expand the file name only, if there is already a connection.
3164 (with-parsed-tramp-file-name
3165 (if c (expand-file-name filename) filename) nil
3166 (and (or (not connected) c)
3167 (cond
3168 ((eq identification 'method) method)
3169 ((eq identification 'user) user)
3170 ((eq identification 'host) host)
3171 ((eq identification 'localname) localname)
3172 (t (tramp-make-tramp-file-name method user host "")))))))))
3173
3174(defun tramp-handle-insert-file-contents
3175 (filename &optional visit beg end replace)
3176 "Like `insert-file-contents' for Tramp files."
3177 (barf-if-buffer-read-only)
3178 (setq filename (expand-file-name filename))
3179 (let (result local-copy remote-copy)
3180 (with-parsed-tramp-file-name filename nil
3181 (unwind-protect
3182 (if (not (file-exists-p filename))
3183 ;; We don't raise a Tramp error, because it might be
3184 ;; suppressed, like in `find-file-noselect-1'.
3185 (signal 'file-error
3186 (list "File not found on remote host" filename))
3187
3188 (if (and (tramp-local-host-p v)
3189 (let (file-name-handler-alist)
3190 (file-readable-p localname)))
3191 ;; Short track: if we are on the local host, we can
3192 ;; run directly.
3193 (setq result
3194 (tramp-run-real-handler
3195 'insert-file-contents
3196 (list localname visit beg end replace)))
3197
3198 ;; When we shall insert only a part of the file, we copy
3199 ;; this part.
3200 (when (or beg end)
3201 (setq remote-copy (tramp-make-tramp-temp-file v))
3202 (tramp-send-command
3203 v
3204 (cond
3205 ((and beg end)
3206 (format "tail -c +%d %s | head -c +%d >%s"
3207 (1+ beg) (tramp-shell-quote-argument localname)
3208 (- end beg) remote-copy))
3209 (beg
3210 (format "tail -c +%d %s >%s"
3211 (1+ beg) (tramp-shell-quote-argument localname)
3212 remote-copy))
3213 (end
3214 (format "head -c +%d %s >%s"
3215 (1+ end) (tramp-shell-quote-argument localname)
3216 remote-copy)))))
3217
3218 ;; `insert-file-contents-literally' takes care to avoid
3219 ;; calling jka-compr. By let-binding
3220 ;; `inhibit-file-name-operation', we propagate that care
3221 ;; to the `file-local-copy' operation.
3222 (setq local-copy
3223 (let ((inhibit-file-name-operation
3224 (when (eq inhibit-file-name-operation
3225 'insert-file-contents)
3226 'file-local-copy)))
3227 (cond
3228 ((stringp remote-copy)
3229 (file-local-copy
3230 (tramp-make-tramp-file-name
3231 method user host remote-copy)))
3232 ((stringp tramp-temp-buffer-file-name)
3233 (copy-file filename tramp-temp-buffer-file-name 'ok)
3234 tramp-temp-buffer-file-name)
3235 (t (file-local-copy filename)))))
3236
3237 ;; When the file is not readable for the owner, it
3238 ;; cannot be inserted, even it is redable for the group
3239 ;; or for everybody.
3240 (set-file-modes local-copy (tramp-compat-octal-to-decimal "0600"))
3241
3242 (when (and (null remote-copy)
3243 (tramp-get-method-parameter
3244 method 'tramp-copy-keep-tmpfile))
3245 ;; We keep the local file for performance reasons,
3246 ;; useful for "rsync".
3247 (setq tramp-temp-buffer-file-name local-copy)
3248 (put 'tramp-temp-buffer-file-name 'permanent-local t))
3249
3250 (with-progress-reporter
3251 v 3 (format "Inserting local temp file `%s'" local-copy)
3252 ;; We must ensure that `file-coding-system-alist'
3253 ;; matches `local-copy'.
3254 (let ((file-coding-system-alist
3255 (tramp-find-file-name-coding-system-alist
3256 filename local-copy)))
3257 (setq result
3258 (insert-file-contents
3259 local-copy nil nil nil replace))))))
3260
3261 ;; Save exit.
3262 (progn
3263 (when visit
3264 (setq buffer-file-name filename)
3265 (setq buffer-read-only (not (file-writable-p filename)))
3266 (set-visited-file-modtime)
3267 (set-buffer-modified-p nil))
3268 (when (and (stringp local-copy)
3269 (or remote-copy (null tramp-temp-buffer-file-name)))
3270 (delete-file local-copy))
3271 (when (stringp remote-copy)
3272 (delete-file
3273 (tramp-make-tramp-file-name method user host remote-copy))))))
3274
3275 ;; Result.
3276 (list (expand-file-name filename)
3277 (cadr result))))
3278
3279;; This is needed for XEmacs only. Code stolen from files.el. 2978;; This is needed for XEmacs only. Code stolen from files.el.
3280(defun tramp-handle-insert-file-contents-literally 2979(defun tramp-sh-handle-insert-file-contents-literally
3281 (filename &optional visit beg end replace) 2980 (filename &optional visit beg end replace)
3282 "Like `insert-file-contents-literally' for Tramp files." 2981 "Like `insert-file-contents-literally' for Tramp files."
3283 (let ((format-alist nil) 2982 (let ((format-alist nil)
@@ -3299,49 +2998,7 @@ beginning of local filename are not substituted."
3299 (fset 'find-buffer-file-type find-buffer-file-type-function) 2998 (fset 'find-buffer-file-type find-buffer-file-type-function)
3300 (fmakunbound 'find-buffer-file-type))))) 2999 (fmakunbound 'find-buffer-file-type)))))
3301 3000
3302(defun tramp-handle-find-backup-file-name (filename) 3001(defun tramp-sh-handle-make-auto-save-file-name ()
3303 "Like `find-backup-file-name' for Tramp files."
3304 (with-parsed-tramp-file-name filename nil
3305 ;; We set both variables. It doesn't matter whether it is
3306 ;; Emacs or XEmacs.
3307 (let ((backup-directory-alist
3308 ;; Emacs case.
3309 (when (boundp 'backup-directory-alist)
3310 (if (symbol-value 'tramp-backup-directory-alist)
3311 (mapcar
3312 (lambda (x)
3313 (cons
3314 (car x)
3315 (if (and (stringp (cdr x))
3316 (file-name-absolute-p (cdr x))
3317 (not (tramp-file-name-p (cdr x))))
3318 (tramp-make-tramp-file-name method user host (cdr x))
3319 (cdr x))))
3320 (symbol-value 'tramp-backup-directory-alist))
3321 (symbol-value 'backup-directory-alist))))
3322
3323 (bkup-backup-directory-info
3324 ;; XEmacs case.
3325 (when (boundp 'bkup-backup-directory-info)
3326 (if (symbol-value 'tramp-bkup-backup-directory-info)
3327 (mapcar
3328 (lambda (x)
3329 (nconc
3330 (list (car x))
3331 (list
3332 (if (and (stringp (car (cdr x)))
3333 (file-name-absolute-p (car (cdr x)))
3334 (not (tramp-file-name-p (car (cdr x)))))
3335 (tramp-make-tramp-file-name
3336 method user host (car (cdr x)))
3337 (car (cdr x))))
3338 (cdr (cdr x))))
3339 (symbol-value 'tramp-bkup-backup-directory-info))
3340 (symbol-value 'bkup-backup-directory-info)))))
3341
3342 (tramp-run-real-handler 'find-backup-file-name (list filename)))))
3343
3344(defun tramp-handle-make-auto-save-file-name ()
3345 "Like `make-auto-save-file-name' for Tramp files. 3002 "Like `make-auto-save-file-name' for Tramp files.
3346Returns a file name in `tramp-auto-save-directory' for autosaving this file." 3003Returns a file name in `tramp-auto-save-directory' for autosaving this file."
3347 (let ((tramp-auto-save-directory tramp-auto-save-directory) 3004 (let ((tramp-auto-save-directory tramp-auto-save-directory)
@@ -3383,11 +3040,8 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file."
3383 (tramp-run-real-handler 'make-auto-save-file-name nil) 3040 (tramp-run-real-handler 'make-auto-save-file-name nil)
3384 (ad-activate 'make-auto-save-file-name))))) 3041 (ad-activate 'make-auto-save-file-name)))))
3385 3042
3386(defvar tramp-handle-write-region-hook nil
3387 "Normal hook to be run at the end of `tramp-handle-write-region'.")
3388
3389;; CCC grok LOCKNAME 3043;; CCC grok LOCKNAME
3390(defun tramp-handle-write-region 3044(defun tramp-sh-handle-write-region
3391 (start end filename &optional append visit lockname confirm) 3045 (start end filename &optional append visit lockname confirm)
3392 "Like `write-region' for Tramp files." 3046 "Like `write-region' for Tramp files."
3393 (setq filename (expand-file-name filename)) 3047 (setq filename (expand-file-name filename))
@@ -3400,7 +3054,7 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file."
3400 ;; (unless (or (eq lockname nil) 3054 ;; (unless (or (eq lockname nil)
3401 ;; (string= lockname filename)) 3055 ;; (string= lockname filename))
3402 ;; (error 3056 ;; (error
3403 ;; "tramp-handle-write-region: LOCKNAME must be nil or equal FILENAME")) 3057 ;; "tramp-sh-handle-write-region: LOCKNAME must be nil or equal FILENAME"))
3404 3058
3405 ;; XEmacs takes a coding system as the seventh argument, not `confirm'. 3059 ;; XEmacs takes a coding system as the seventh argument, not `confirm'.
3406 (when (and (not (featurep 'xemacs)) confirm (file-exists-p filename)) 3060 (when (and (not (featurep 'xemacs)) confirm (file-exists-p filename))
@@ -3649,7 +3303,7 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file."
3649;; can reset the file name handlers, and we make a second run of 3303;; can reset the file name handlers, and we make a second run of
3650;; `vc-registered', which returns the expected result without sending 3304;; `vc-registered', which returns the expected result without sending
3651;; any other remote command. 3305;; any other remote command.
3652(defun tramp-handle-vc-registered (file) 3306(defun tramp-sh-handle-vc-registered (file)
3653 "Like `vc-registered' for Tramp files." 3307 "Like `vc-registered' for Tramp files."
3654 (tramp-compat-with-temp-message "" 3308 (tramp-compat-with-temp-message ""
3655 (with-parsed-tramp-file-name file nil 3309 (with-parsed-tramp-file-name file nil
@@ -4791,77 +4445,6 @@ In case there is no valid Lisp expression, it raises an error"
4791 "`%s' does not return a valid Lisp expression: `%s'" 4445 "`%s' does not return a valid Lisp expression: `%s'"
4792 command (buffer-string)))))) 4446 command (buffer-string))))))
4793 4447
4794(defun tramp-mode-string-to-int (mode-string)
4795 "Converts a ten-letter `drwxrwxrwx'-style mode string into mode bits."
4796 (let* (case-fold-search
4797 (mode-chars (string-to-vector mode-string))
4798 (owner-read (aref mode-chars 1))
4799 (owner-write (aref mode-chars 2))
4800 (owner-execute-or-setid (aref mode-chars 3))
4801 (group-read (aref mode-chars 4))
4802 (group-write (aref mode-chars 5))
4803 (group-execute-or-setid (aref mode-chars 6))
4804 (other-read (aref mode-chars 7))
4805 (other-write (aref mode-chars 8))
4806 (other-execute-or-sticky (aref mode-chars 9)))
4807 (save-match-data
4808 (logior
4809 (cond
4810 ((char-equal owner-read ?r) (tramp-compat-octal-to-decimal "00400"))
4811 ((char-equal owner-read ?-) 0)
4812 (t (error "Second char `%c' must be one of `r-'" owner-read)))
4813 (cond
4814 ((char-equal owner-write ?w) (tramp-compat-octal-to-decimal "00200"))
4815 ((char-equal owner-write ?-) 0)
4816 (t (error "Third char `%c' must be one of `w-'" owner-write)))
4817 (cond
4818 ((char-equal owner-execute-or-setid ?x)
4819 (tramp-compat-octal-to-decimal "00100"))
4820 ((char-equal owner-execute-or-setid ?S)
4821 (tramp-compat-octal-to-decimal "04000"))
4822 ((char-equal owner-execute-or-setid ?s)
4823 (tramp-compat-octal-to-decimal "04100"))
4824 ((char-equal owner-execute-or-setid ?-) 0)
4825 (t (error "Fourth char `%c' must be one of `xsS-'"
4826 owner-execute-or-setid)))
4827 (cond
4828 ((char-equal group-read ?r) (tramp-compat-octal-to-decimal "00040"))
4829 ((char-equal group-read ?-) 0)
4830 (t (error "Fifth char `%c' must be one of `r-'" group-read)))
4831 (cond
4832 ((char-equal group-write ?w) (tramp-compat-octal-to-decimal "00020"))
4833 ((char-equal group-write ?-) 0)
4834 (t (error "Sixth char `%c' must be one of `w-'" group-write)))
4835 (cond
4836 ((char-equal group-execute-or-setid ?x)
4837 (tramp-compat-octal-to-decimal "00010"))
4838 ((char-equal group-execute-or-setid ?S)
4839 (tramp-compat-octal-to-decimal "02000"))
4840 ((char-equal group-execute-or-setid ?s)
4841 (tramp-compat-octal-to-decimal "02010"))
4842 ((char-equal group-execute-or-setid ?-) 0)
4843 (t (error "Seventh char `%c' must be one of `xsS-'"
4844 group-execute-or-setid)))
4845 (cond
4846 ((char-equal other-read ?r)
4847 (tramp-compat-octal-to-decimal "00004"))
4848 ((char-equal other-read ?-) 0)
4849 (t (error "Eighth char `%c' must be one of `r-'" other-read)))
4850 (cond
4851 ((char-equal other-write ?w) (tramp-compat-octal-to-decimal "00002"))
4852 ((char-equal other-write ?-) 0)
4853 (t (error "Nineth char `%c' must be one of `w-'" other-write)))
4854 (cond
4855 ((char-equal other-execute-or-sticky ?x)
4856 (tramp-compat-octal-to-decimal "00001"))
4857 ((char-equal other-execute-or-sticky ?T)
4858 (tramp-compat-octal-to-decimal "01000"))
4859 ((char-equal other-execute-or-sticky ?t)
4860 (tramp-compat-octal-to-decimal "01001"))
4861 ((char-equal other-execute-or-sticky ?-) 0)
4862 (t (error "Tenth char `%c' must be one of `xtT-'"
4863 other-execute-or-sticky)))))))
4864
4865(defun tramp-convert-file-attributes (vec attr) 4448(defun tramp-convert-file-attributes (vec attr)
4866 "Convert file-attributes ATTR generated by perl script, stat or ls. 4449 "Convert file-attributes ATTR generated by perl script, stat or ls.
4867Convert file mode bits to string and set virtual device number. 4450Convert file mode bits to string and set virtual device number.
@@ -5024,30 +4607,6 @@ This is used internally by `tramp-file-mode-from-int'."
5024 (> size tramp-copy-size-limit) 4607 (> size tramp-copy-size-limit)
5025 (null (tramp-get-inline-coding vec "remote-encoding" size))))) 4608 (null (tramp-get-inline-coding vec "remote-encoding" size)))))
5026 4609
5027(defun tramp-local-host-p (vec)
5028 "Return t if this points to the local host, nil otherwise."
5029 ;; We cannot use `tramp-file-name-real-host'. A port is an
5030 ;; indication for an ssh tunnel or alike.
5031 (let ((host (tramp-file-name-host vec)))
5032 (and
5033 (stringp host)
5034 (string-match tramp-local-host-regexp host)
5035 ;; The method shall be applied to one of the shell file name
5036 ;; handler. `tramp-local-host-p' is also called for "smb" and
5037 ;; alike, where it must fail.
5038 (tramp-get-method-parameter
5039 (tramp-file-name-method vec) 'tramp-login-program)
5040 ;; The local temp directory must be writable for the other user.
5041 (file-writable-p
5042 (tramp-make-tramp-file-name
5043 (tramp-file-name-method vec)
5044 (tramp-file-name-user vec)
5045 host
5046 (tramp-compat-temporary-file-directory)))
5047 ;; On some systems, chown runs only for root.
5048 (or (zerop (user-uid))
5049 (zerop (tramp-get-remote-uid vec 'integer))))))
5050
5051;; Variables local to connection. 4610;; Variables local to connection.
5052 4611
5053(defun tramp-get-remote-path (vec) 4612(defun tramp-get-remote-path (vec)
@@ -5133,33 +4692,6 @@ This is used internally by `tramp-file-mode-from-int'."
5133 dir 4692 dir
5134 (tramp-error vec 'file-error "Directory %s not accessible" dir))))) 4693 (tramp-error vec 'file-error "Directory %s not accessible" dir)))))
5135 4694
5136(defun tramp-make-tramp-temp-file (vec)
5137 "Create a temporary file on the remote host identified by VEC.
5138Return the local name of the temporary file."
5139 (let ((prefix
5140 (tramp-make-tramp-file-name
5141 (tramp-file-name-method vec)
5142 (tramp-file-name-user vec)
5143 (tramp-file-name-host vec)
5144 (tramp-drop-volume-letter
5145 (expand-file-name
5146 tramp-temp-name-prefix (tramp-get-remote-tmpdir vec)))))
5147 result)
5148 (while (not result)
5149 ;; `make-temp-file' would be the natural choice for
5150 ;; implementation. But it calls `write-region' internally,
5151 ;; which also needs a temporary file - we would end in an
5152 ;; infinite loop.
5153 (setq result (make-temp-name prefix))
5154 (if (file-exists-p result)
5155 (setq result nil)
5156 ;; This creates the file by side effect.
5157 (set-file-times result)
5158 (set-file-modes result (tramp-compat-octal-to-decimal "0700"))))
5159
5160 ;; Return the local part.
5161 (with-parsed-tramp-file-name result nil localname)))
5162
5163(defun tramp-get-ls-command (vec) 4695(defun tramp-get-ls-command (vec)
5164 (with-connection-property vec "ls" 4696 (with-connection-property vec "ls"
5165 (tramp-message vec 5 "Finding a suitable `ls' command") 4697 (tramp-message vec 5 "Finding a suitable `ls' command")
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index e48a8b321fd..84d11972115 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -31,10 +31,6 @@
31(eval-when-compile (require 'cl)) ; block, return 31(eval-when-compile (require 'cl)) ; block, return
32(require 'tramp) 32(require 'tramp)
33 33
34;; We call several `tramp-handle-*' functions directly. So we must
35;; reqire that package as well.
36(require 'tramp-sh)
37
38;; Define SMB method ... 34;; Define SMB method ...
39;;;###tramp-autoload 35;;;###tramp-autoload
40(defconst tramp-smb-method "smb" 36(defconst tramp-smb-method "smb"
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index fa61aa02d70..1ad5c3aac2c 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -761,7 +761,7 @@ Derived from `tramp-postfix-host-format'.")
761(defconst tramp-localname-regexp ".*$" 761(defconst tramp-localname-regexp ".*$"
762 "*Regexp matching localnames.") 762 "*Regexp matching localnames.")
763 763
764;; File name format. 764;;; File name format:
765 765
766(defconst tramp-file-name-structure 766(defconst tramp-file-name-structure
767 (list 767 (list
@@ -1009,10 +1009,6 @@ calling HANDLER.")
1009 1009
1010;;; Internal functions which must come first: 1010;;; Internal functions which must come first:
1011 1011
1012
1013;; ------------------------------------------------------------
1014;; -- Tramp file names --
1015;; ------------------------------------------------------------
1016;; Conversion functions between external representation and 1012;; Conversion functions between external representation and
1017;; internal data structure. Convenience functions for internal 1013;; internal data structure. Convenience functions for internal
1018;; data structure. 1014;; data structure.
@@ -1658,9 +1654,6 @@ Return the string with the replaced variables."
1658 '(minibuffer-electric-separator 1654 '(minibuffer-electric-separator
1659 minibuffer-electric-tilde))) 1655 minibuffer-electric-tilde)))
1660 1656
1661(defvar tramp-handle-file-local-copy-hook nil
1662 "Normal hook to be run at the end of `tramp-handle-file-local-copy'.")
1663
1664(defun tramp-find-file-name-coding-system-alist (filename tmpname) 1657(defun tramp-find-file-name-coding-system-alist (filename tmpname)
1665 "Like `find-operation-coding-system' for Tramp filenames. 1658 "Like `find-operation-coding-system' for Tramp filenames.
1666Tramp's `insert-file-contents' and `write-region' work over 1659Tramp's `insert-file-contents' and `write-region' work over
@@ -1952,9 +1945,29 @@ Falls back to normal file name handler if no Tramp file name handler exists."
1952;; `tramp-file-name-handler' must be registered before evaluation of 1945;; `tramp-file-name-handler' must be registered before evaluation of
1953;; site-start and init files, because there might exist remote files 1946;; site-start and init files, because there might exist remote files
1954;; already, f.e. files kept via recentf-mode. 1947;; already, f.e. files kept via recentf-mode.
1955;;;###autoload(tramp-register-file-name-handlers) 1948;;;###autoload
1956(tramp-register-file-name-handlers) 1949(tramp-register-file-name-handlers)
1957 1950
1951(defun tramp-exists-file-name-handler (operation &rest args)
1952 "Check, whether OPERATION runs a file name handler."
1953 ;; The file name handler is determined on base of either an
1954 ;; argument, `buffer-file-name', or `default-directory'.
1955 (ignore-errors
1956 (let* ((buffer-file-name "/")
1957 (default-directory "/")
1958 (fnha file-name-handler-alist)
1959 (check-file-name-operation operation)
1960 (file-name-handler-alist
1961 (list
1962 (cons "/"
1963 (lambda (operation &rest args)
1964 "Returns OPERATION if it is the one to be checked."
1965 (if (equal check-file-name-operation operation)
1966 operation
1967 (let ((file-name-handler-alist fnha))
1968 (apply operation args))))))))
1969 (equal (apply operation args) operation))))
1970
1958;;;###autoload 1971;;;###autoload
1959(defun tramp-unload-file-name-handlers () 1972(defun tramp-unload-file-name-handlers ()
1960 (setq file-name-handler-alist 1973 (setq file-name-handler-alist
@@ -2554,20 +2567,360 @@ User is always nil."
2554 (forward-line 1) 2567 (forward-line 1)
2555 result)) 2568 result))
2556 2569
2557(defun tramp-delete-temp-file-function () 2570;;; Common file name handler functions for different backends:
2558 "Remove temporary files related to current buffer."
2559 (when (stringp tramp-temp-buffer-file-name)
2560 (ignore-errors (delete-file tramp-temp-buffer-file-name))))
2561 2571
2562(add-hook 'kill-buffer-hook 'tramp-delete-temp-file-function) 2572(defvar tramp-handle-file-local-copy-hook nil
2563(add-hook 'tramp-cache-unload-hook 2573 "Normal hook to be run at the end of `tramp-*-handle-file-local-copy'.")
2564 (lambda () 2574
2565 (remove-hook 'kill-buffer-hook 2575(defvar tramp-handle-write-region-hook nil
2566 'tramp-delete-temp-file-function))) 2576 "Normal hook to be run at the end of `tramp-*-handle-write-region'.")
2577
2578(defun tramp-handle-directory-file-name (directory)
2579 "Like `directory-file-name' for Tramp files."
2580 ;; If localname component of filename is "/", leave it unchanged.
2581 ;; Otherwise, remove any trailing slash from localname component.
2582 ;; Method, host, etc, are unchanged. Does it make sense to try
2583 ;; to avoid parsing the filename?
2584 (with-parsed-tramp-file-name directory nil
2585 (if (and (not (zerop (length localname)))
2586 (eq (aref localname (1- (length localname))) ?/)
2587 (not (string= localname "/")))
2588 (substring directory 0 -1)
2589 directory)))
2590
2591(defun tramp-handle-directory-files
2592 (directory &optional full match nosort files-only)
2593 "Like `directory-files' for Tramp files."
2594 ;; FILES-ONLY is valid for XEmacs only.
2595 (when (file-directory-p directory)
2596 (setq directory (file-name-as-directory (expand-file-name directory)))
2597 (let ((temp (nreverse (file-name-all-completions "" directory)))
2598 result item)
2599
2600 (while temp
2601 (setq item (directory-file-name (pop temp)))
2602 (when (and (or (null match) (string-match match item))
2603 (or (null files-only)
2604 ;; Files only.
2605 (and (equal files-only t) (file-regular-p item))
2606 ;; Directories only.
2607 (file-directory-p item)))
2608 (push (if full (concat directory item) item)
2609 result)))
2610 (if nosort result (sort result 'string<)))))
2611
2612(defun tramp-handle-dired-uncache (dir &optional dir-p)
2613 "Like `dired-uncache' for Tramp files."
2614 ;; DIR-P is valid for XEmacs only.
2615 (with-parsed-tramp-file-name
2616 (if (or dir-p (file-directory-p dir)) dir (file-name-directory dir)) nil
2617 (tramp-flush-directory-property v localname)))
2618
2619(defun tramp-handle-file-modes (filename)
2620 "Like `file-modes' for Tramp files."
2621 (let ((truename (or (file-truename filename) filename)))
2622 (when (file-exists-p truename)
2623 (tramp-mode-string-to-int (nth 8 (file-attributes truename))))))
2624
2625;; Localname manipulation functions that grok Tramp localnames...
2626(defun tramp-handle-file-name-as-directory (file)
2627 "Like `file-name-as-directory' but aware of Tramp files."
2628 ;; `file-name-as-directory' would be sufficient except localname is
2629 ;; the empty string.
2630 (let ((v (tramp-dissect-file-name file t)))
2631 ;; Run the command on the localname portion only.
2632 (tramp-make-tramp-file-name
2633 (tramp-file-name-method v)
2634 (tramp-file-name-user v)
2635 (tramp-file-name-host v)
2636 (tramp-run-real-handler
2637 'file-name-as-directory (list (or (tramp-file-name-localname v) ""))))))
2638
2639(defun tramp-handle-file-name-completion
2640 (filename directory &optional predicate)
2641 "Like `file-name-completion' for Tramp files."
2642 (unless (tramp-tramp-file-p directory)
2643 (error
2644 "tramp-handle-file-name-completion invoked on non-tramp directory `%s'"
2645 directory))
2646 (try-completion
2647 filename
2648 (mapcar 'list (file-name-all-completions filename directory))
2649 (when predicate
2650 (lambda (x) (funcall predicate (expand-file-name (car x) directory))))))
2651
2652(defun tramp-handle-file-name-directory (file)
2653 "Like `file-name-directory' but aware of Tramp files."
2654 ;; Everything except the last filename thing is the directory. We
2655 ;; cannot apply `with-parsed-tramp-file-name', because this expands
2656 ;; the remote file name parts. This is a problem when we are in
2657 ;; file name completion.
2658 (let ((v (tramp-dissect-file-name file t)))
2659 ;; Run the command on the localname portion only.
2660 (tramp-make-tramp-file-name
2661 (tramp-file-name-method v)
2662 (tramp-file-name-user v)
2663 (tramp-file-name-host v)
2664 (tramp-run-real-handler
2665 'file-name-directory (list (or (tramp-file-name-localname v) ""))))))
2666
2667(defun tramp-handle-file-name-nondirectory (file)
2668 "Like `file-name-nondirectory' but aware of Tramp files."
2669 (with-parsed-tramp-file-name file nil
2670 (tramp-run-real-handler 'file-name-nondirectory (list localname))))
2671
2672(defun tramp-handle-file-regular-p (filename)
2673 "Like `file-regular-p' for Tramp files."
2674 (and (file-exists-p filename)
2675 (eq ?- (aref (nth 8 (file-attributes filename)) 0))))
2676
2677(defun tramp-handle-file-remote-p (filename &optional identification connected)
2678 "Like `file-remote-p' for Tramp files."
2679 (let ((tramp-verbose 3))
2680 (when (tramp-tramp-file-p filename)
2681 (let* ((v (tramp-dissect-file-name filename))
2682 (p (tramp-get-connection-process v))
2683 (c (and p (processp p) (memq (process-status p) '(run open)))))
2684 ;; We expand the file name only, if there is already a connection.
2685 (with-parsed-tramp-file-name
2686 (if c (expand-file-name filename) filename) nil
2687 (and (or (not connected) c)
2688 (cond
2689 ((eq identification 'method) method)
2690 ((eq identification 'user) user)
2691 ((eq identification 'host) host)
2692 ((eq identification 'localname) localname)
2693 (t (tramp-make-tramp-file-name method user host "")))))))))
2694
2695(defun tramp-handle-file-symlink-p (filename)
2696 "Like `file-symlink-p' for Tramp files."
2697 (with-parsed-tramp-file-name filename nil
2698 (let ((x (car (file-attributes filename))))
2699 (when (stringp x)
2700 ;; When Tramp is running on VMS, then `file-name-absolute-p'
2701 ;; might do weird things.
2702 (if (file-name-absolute-p x)
2703 (tramp-make-tramp-file-name method user host x)
2704 x)))))
2705
2706(defun tramp-handle-find-backup-file-name (filename)
2707 "Like `find-backup-file-name' for Tramp files."
2708 (with-parsed-tramp-file-name filename nil
2709 ;; We set both variables. It doesn't matter whether it is
2710 ;; Emacs or XEmacs.
2711 (let ((backup-directory-alist
2712 ;; Emacs case.
2713 (when (boundp 'backup-directory-alist)
2714 (if (symbol-value 'tramp-backup-directory-alist)
2715 (mapcar
2716 (lambda (x)
2717 (cons
2718 (car x)
2719 (if (and (stringp (cdr x))
2720 (file-name-absolute-p (cdr x))
2721 (not (tramp-file-name-p (cdr x))))
2722 (tramp-make-tramp-file-name method user host (cdr x))
2723 (cdr x))))
2724 (symbol-value 'tramp-backup-directory-alist))
2725 (symbol-value 'backup-directory-alist))))
2726
2727 (bkup-backup-directory-info
2728 ;; XEmacs case.
2729 (when (boundp 'bkup-backup-directory-info)
2730 (if (symbol-value 'tramp-bkup-backup-directory-info)
2731 (mapcar
2732 (lambda (x)
2733 (nconc
2734 (list (car x))
2735 (list
2736 (if (and (stringp (car (cdr x)))
2737 (file-name-absolute-p (car (cdr x)))
2738 (not (tramp-file-name-p (car (cdr x)))))
2739 (tramp-make-tramp-file-name
2740 method user host (car (cdr x)))
2741 (car (cdr x))))
2742 (cdr (cdr x))))
2743 (symbol-value 'tramp-bkup-backup-directory-info))
2744 (symbol-value 'bkup-backup-directory-info)))))
2745
2746 (tramp-run-real-handler 'find-backup-file-name (list filename)))))
2747
2748(defun tramp-handle-insert-file-contents
2749 (filename &optional visit beg end replace)
2750 "Like `insert-file-contents' for Tramp files."
2751 (barf-if-buffer-read-only)
2752 (setq filename (expand-file-name filename))
2753 (let (result local-copy remote-copy)
2754 (with-parsed-tramp-file-name filename nil
2755 (unwind-protect
2756 (if (not (file-exists-p filename))
2757 ;; We don't raise a Tramp error, because it might be
2758 ;; suppressed, like in `find-file-noselect-1'.
2759 (signal 'file-error
2760 (list "File not found on remote host" filename))
2761
2762 (if (and (tramp-local-host-p v)
2763 (let (file-name-handler-alist)
2764 (file-readable-p localname)))
2765 ;; Short track: if we are on the local host, we can
2766 ;; run directly.
2767 (setq result
2768 (tramp-run-real-handler
2769 'insert-file-contents
2770 (list localname visit beg end replace)))
2771
2772 ;; When we shall insert only a part of the file, we copy
2773 ;; this part.
2774 (when (or beg end)
2775 (setq remote-copy (tramp-make-tramp-temp-file v))
2776 ;; This is defined in tramp-sh.el. Let's assume this
2777 ;; is loaded already.
2778 (tramp-compat-funcall 'tramp-send-command
2779 v
2780 (cond
2781 ((and beg end)
2782 (format "tail -c +%d %s | head -c +%d >%s"
2783 (1+ beg) (tramp-shell-quote-argument localname)
2784 (- end beg) remote-copy))
2785 (beg
2786 (format "tail -c +%d %s >%s"
2787 (1+ beg) (tramp-shell-quote-argument localname)
2788 remote-copy))
2789 (end
2790 (format "head -c +%d %s >%s"
2791 (1+ end) (tramp-shell-quote-argument localname)
2792 remote-copy)))))
2793
2794 ;; `insert-file-contents-literally' takes care to avoid
2795 ;; calling jka-compr. By let-binding
2796 ;; `inhibit-file-name-operation', we propagate that care
2797 ;; to the `file-local-copy' operation.
2798 (setq local-copy
2799 (let ((inhibit-file-name-operation
2800 (when (eq inhibit-file-name-operation
2801 'insert-file-contents)
2802 'file-local-copy)))
2803 (cond
2804 ((stringp remote-copy)
2805 (file-local-copy
2806 (tramp-make-tramp-file-name
2807 method user host remote-copy)))
2808 ((stringp tramp-temp-buffer-file-name)
2809 (copy-file filename tramp-temp-buffer-file-name 'ok)
2810 tramp-temp-buffer-file-name)
2811 (t (file-local-copy filename)))))
2812
2813 ;; When the file is not readable for the owner, it
2814 ;; cannot be inserted, even it is redable for the group
2815 ;; or for everybody.
2816 (set-file-modes local-copy (tramp-compat-octal-to-decimal "0600"))
2817
2818 (when (and (null remote-copy)
2819 (tramp-get-method-parameter
2820 method 'tramp-copy-keep-tmpfile))
2821 ;; We keep the local file for performance reasons,
2822 ;; useful for "rsync".
2823 (setq tramp-temp-buffer-file-name local-copy)
2824 (put 'tramp-temp-buffer-file-name 'permanent-local t))
2825
2826 (with-progress-reporter
2827 v 3 (format "Inserting local temp file `%s'" local-copy)
2828 ;; We must ensure that `file-coding-system-alist'
2829 ;; matches `local-copy'.
2830 (let ((file-coding-system-alist
2831 (tramp-find-file-name-coding-system-alist
2832 filename local-copy)))
2833 (setq result
2834 (insert-file-contents
2835 local-copy nil nil nil replace))))))
2836
2837 ;; Save exit.
2838 (progn
2839 (when visit
2840 (setq buffer-file-name filename)
2841 (setq buffer-read-only (not (file-writable-p filename)))
2842 (set-visited-file-modtime)
2843 (set-buffer-modified-p nil))
2844 (when (and (stringp local-copy)
2845 (or remote-copy (null tramp-temp-buffer-file-name)))
2846 (delete-file local-copy))
2847 (when (stringp remote-copy)
2848 (delete-file
2849 (tramp-make-tramp-file-name method user host remote-copy))))))
2850
2851 ;; Result.
2852 (list (expand-file-name filename)
2853 (cadr result))))
2854
2855(defun tramp-handle-load (file &optional noerror nomessage nosuffix must-suffix)
2856 "Like `load' for Tramp files."
2857 (with-parsed-tramp-file-name (expand-file-name file) nil
2858 (unless nosuffix
2859 (cond ((file-exists-p (concat file ".elc"))
2860 (setq file (concat file ".elc")))
2861 ((file-exists-p (concat file ".el"))
2862 (setq file (concat file ".el")))))
2863 (when must-suffix
2864 ;; The first condition is always true for absolute file names.
2865 ;; Included for safety's sake.
2866 (unless (or (file-name-directory file)
2867 (string-match "\\.elc?\\'" file))
2868 (tramp-error
2869 v 'file-error
2870 "File `%s' does not include a `.el' or `.elc' suffix" file)))
2871 (unless noerror
2872 (when (not (file-exists-p file))
2873 (tramp-error v 'file-error "Cannot load nonexistent file `%s'" file)))
2874 (if (not (file-exists-p file))
2875 nil
2876 (let ((tramp-message-show-message (not nomessage)))
2877 (with-progress-reporter v 0 (format "Loading %s" file)
2878 (let ((local-copy (file-local-copy file)))
2879 ;; MUST-SUFFIX doesn't exist on XEmacs, so let it default to nil.
2880 (unwind-protect
2881 (load local-copy noerror t t)
2882 (delete-file local-copy)))))
2883 t)))
2884
2885(defun tramp-handle-substitute-in-file-name (filename)
2886 "Like `substitute-in-file-name' for Tramp files.
2887\"//\" and \"/~\" substitute only in the local filename part.
2888If the URL Tramp syntax is chosen, \"//\" as method delimeter and \"/~\" at
2889beginning of local filename are not substituted."
2890 ;; First, we must replace environment variables.
2891 (setq filename (tramp-replace-environment-variables filename))
2892 (with-parsed-tramp-file-name filename nil
2893 (if (equal tramp-syntax 'url)
2894 ;; We need to check localname only. The other parts cannot contain
2895 ;; "//" or "/~".
2896 (if (and (> (length localname) 1)
2897 (or (string-match "//" localname)
2898 (string-match "/~" localname 1)))
2899 (tramp-run-real-handler 'substitute-in-file-name (list filename))
2900 (tramp-make-tramp-file-name
2901 (when method (substitute-in-file-name method))
2902 (when user (substitute-in-file-name user))
2903 (when host (substitute-in-file-name host))
2904 (when localname
2905 (tramp-run-real-handler
2906 'substitute-in-file-name (list localname)))))
2907 ;; Ignore in LOCALNAME everything before "//" or "/~".
2908 (when (and (stringp localname) (string-match ".+?/\\(/\\|~\\)" localname))
2909 (setq filename
2910 (concat (file-remote-p filename)
2911 (replace-match "\\1" nil nil localname)))
2912 ;; "/m:h:~" does not work for completion. We use "/m:h:~/".
2913 (when (string-match "~$" filename)
2914 (setq filename (concat filename "/"))))
2915 (tramp-run-real-handler 'substitute-in-file-name (list filename)))))
2916
2917(defun tramp-handle-unhandled-file-name-directory (filename)
2918 "Like `unhandled-file-name-directory' for Tramp files."
2919 ;; With Emacs 23, we could simply return `nil'. But we must keep it
2920 ;; for backward compatibility.
2921 (expand-file-name "~/"))
2567 2922
2568;; ------------------------------------------------------------ 2923;;; Functions for establishing connection:
2569;; -- Functions for establishing connection --
2570;; ------------------------------------------------------------
2571 2924
2572;; The following functions are actions to be taken when seeing certain 2925;; The following functions are actions to be taken when seeing certain
2573;; prompts from the remote host. See the variable 2926;; prompts from the remote host. See the variable
@@ -2666,7 +3019,7 @@ The terminal type can be configured with `tramp-terminal-type'."
2666 (throw 'tramp-action 'process-died)))) 3019 (throw 'tramp-action 'process-died))))
2667 (t nil))) 3020 (t nil)))
2668 3021
2669;; Functions for processing the actions. 3022;;; Functions for processing the actions:
2670 3023
2671(defun tramp-process-one-action (proc vec actions) 3024(defun tramp-process-one-action (proc vec actions)
2672 "Wait for output from the shell and perform one action." 3025 "Wait for output from the shell and perform one action."
@@ -2714,7 +3067,7 @@ The terminal type can be configured with `tramp-terminal-type'."
2714 ((eq exit 'process-died) "Process died") 3067 ((eq exit 'process-died) "Process died")
2715 (t "Login failed"))))))) 3068 (t "Login failed")))))))
2716 3069
2717;; Utility functions. 3070:;; Utility functions:
2718 3071
2719(defun tramp-accept-process-output (&optional proc timeout timeout-msecs) 3072(defun tramp-accept-process-output (&optional proc timeout timeout-msecs)
2720 "Like `accept-process-output' for Tramp processes. 3073 "Like `accept-process-output' for Tramp processes.
@@ -2902,27 +3255,145 @@ If the `tramp-methods' entry does not exist, return nil."
2902 (let ((entry (assoc param (assoc method tramp-methods)))) 3255 (let ((entry (assoc param (assoc method tramp-methods))))
2903 (when entry (cadr entry)))) 3256 (when entry (cadr entry))))
2904 3257
2905;; Auto saving to a special directory. 3258(defun tramp-mode-string-to-int (mode-string)
3259 "Converts a ten-letter `drwxrwxrwx'-style mode string into mode bits."
3260 (let* (case-fold-search
3261 (mode-chars (string-to-vector mode-string))
3262 (owner-read (aref mode-chars 1))
3263 (owner-write (aref mode-chars 2))
3264 (owner-execute-or-setid (aref mode-chars 3))
3265 (group-read (aref mode-chars 4))
3266 (group-write (aref mode-chars 5))
3267 (group-execute-or-setid (aref mode-chars 6))
3268 (other-read (aref mode-chars 7))
3269 (other-write (aref mode-chars 8))
3270 (other-execute-or-sticky (aref mode-chars 9)))
3271 (save-match-data
3272 (logior
3273 (cond
3274 ((char-equal owner-read ?r) (tramp-compat-octal-to-decimal "00400"))
3275 ((char-equal owner-read ?-) 0)
3276 (t (error "Second char `%c' must be one of `r-'" owner-read)))
3277 (cond
3278 ((char-equal owner-write ?w) (tramp-compat-octal-to-decimal "00200"))
3279 ((char-equal owner-write ?-) 0)
3280 (t (error "Third char `%c' must be one of `w-'" owner-write)))
3281 (cond
3282 ((char-equal owner-execute-or-setid ?x)
3283 (tramp-compat-octal-to-decimal "00100"))
3284 ((char-equal owner-execute-or-setid ?S)
3285 (tramp-compat-octal-to-decimal "04000"))
3286 ((char-equal owner-execute-or-setid ?s)
3287 (tramp-compat-octal-to-decimal "04100"))
3288 ((char-equal owner-execute-or-setid ?-) 0)
3289 (t (error "Fourth char `%c' must be one of `xsS-'"
3290 owner-execute-or-setid)))
3291 (cond
3292 ((char-equal group-read ?r) (tramp-compat-octal-to-decimal "00040"))
3293 ((char-equal group-read ?-) 0)
3294 (t (error "Fifth char `%c' must be one of `r-'" group-read)))
3295 (cond
3296 ((char-equal group-write ?w) (tramp-compat-octal-to-decimal "00020"))
3297 ((char-equal group-write ?-) 0)
3298 (t (error "Sixth char `%c' must be one of `w-'" group-write)))
3299 (cond
3300 ((char-equal group-execute-or-setid ?x)
3301 (tramp-compat-octal-to-decimal "00010"))
3302 ((char-equal group-execute-or-setid ?S)
3303 (tramp-compat-octal-to-decimal "02000"))
3304 ((char-equal group-execute-or-setid ?s)
3305 (tramp-compat-octal-to-decimal "02010"))
3306 ((char-equal group-execute-or-setid ?-) 0)
3307 (t (error "Seventh char `%c' must be one of `xsS-'"
3308 group-execute-or-setid)))
3309 (cond
3310 ((char-equal other-read ?r)
3311 (tramp-compat-octal-to-decimal "00004"))
3312 ((char-equal other-read ?-) 0)
3313 (t (error "Eighth char `%c' must be one of `r-'" other-read)))
3314 (cond
3315 ((char-equal other-write ?w) (tramp-compat-octal-to-decimal "00002"))
3316 ((char-equal other-write ?-) 0)
3317 (t (error "Nineth char `%c' must be one of `w-'" other-write)))
3318 (cond
3319 ((char-equal other-execute-or-sticky ?x)
3320 (tramp-compat-octal-to-decimal "00001"))
3321 ((char-equal other-execute-or-sticky ?T)
3322 (tramp-compat-octal-to-decimal "01000"))
3323 ((char-equal other-execute-or-sticky ?t)
3324 (tramp-compat-octal-to-decimal "01001"))
3325 ((char-equal other-execute-or-sticky ?-) 0)
3326 (t (error "Tenth char `%c' must be one of `xtT-'"
3327 other-execute-or-sticky)))))))
3328
3329(defun tramp-local-host-p (vec)
3330 "Return t if this points to the local host, nil otherwise."
3331 ;; We cannot use `tramp-file-name-real-host'. A port is an
3332 ;; indication for an ssh tunnel or alike.
3333 (let ((host (tramp-file-name-host vec)))
3334 (and
3335 (stringp host)
3336 (string-match tramp-local-host-regexp host)
3337 ;; The method shall be applied to one of the shell file name
3338 ;; handler. `tramp-local-host-p' is also called for "smb" and
3339 ;; alike, where it must fail.
3340 (tramp-get-method-parameter
3341 (tramp-file-name-method vec) 'tramp-login-program)
3342 ;; The local temp directory must be writable for the other user.
3343 (file-writable-p
3344 (tramp-make-tramp-file-name
3345 (tramp-file-name-method vec)
3346 (tramp-file-name-user vec)
3347 host
3348 (tramp-compat-temporary-file-directory)))
3349 ;; On some systems, chown runs only for root.
3350 (or (zerop (user-uid))
3351 ;; This is defined in tramp-sh.el. Let's assume this is
3352 ;; loaded already.
3353 (zerop (tramp-compat-funcall 'tramp-get-remote-uid vec 'integer))))))
3354
3355(defun tramp-make-tramp-temp-file (vec)
3356 "Create a temporary file on the remote host identified by VEC.
3357Return the local name of the temporary file."
3358 (let ((prefix
3359 (tramp-make-tramp-file-name
3360 (tramp-file-name-method vec)
3361 (tramp-file-name-user vec)
3362 (tramp-file-name-host vec)
3363 (tramp-drop-volume-letter
3364 (expand-file-name
3365 tramp-temp-name-prefix
3366 ;; This is defined in tramp-sh.el. Let's assume this is
3367 ;; loaded already.
3368 (tramp-compat-funcall 'tramp-get-remote-tmpdir vec)))))
3369 result)
3370 (while (not result)
3371 ;; `make-temp-file' would be the natural choice for
3372 ;; implementation. But it calls `write-region' internally,
3373 ;; which also needs a temporary file - we would end in an
3374 ;; infinite loop.
3375 (setq result (make-temp-name prefix))
3376 (if (file-exists-p result)
3377 (setq result nil)
3378 ;; This creates the file by side effect.
3379 (set-file-times result)
3380 (set-file-modes result (tramp-compat-octal-to-decimal "0700"))))
3381
3382 ;; Return the local part.
3383 (with-parsed-tramp-file-name result nil localname)))
2906 3384
2907(defun tramp-exists-file-name-handler (operation &rest args) 3385(defun tramp-delete-temp-file-function ()
2908 "Check, whether OPERATION runs a file name handler." 3386 "Remove temporary files related to current buffer."
2909 ;; The file name handler is determined on base of either an 3387 (when (stringp tramp-temp-buffer-file-name)
2910 ;; argument, `buffer-file-name', or `default-directory'. 3388 (ignore-errors (delete-file tramp-temp-buffer-file-name))))
2911 (ignore-errors 3389
2912 (let* ((buffer-file-name "/") 3390(add-hook 'kill-buffer-hook 'tramp-delete-temp-file-function)
2913 (default-directory "/") 3391(add-hook 'tramp-cache-unload-hook
2914 (fnha file-name-handler-alist) 3392 (lambda ()
2915 (check-file-name-operation operation) 3393 (remove-hook 'kill-buffer-hook
2916 (file-name-handler-alist 3394 'tramp-delete-temp-file-function)))
2917 (list 3395
2918 (cons "/" 3396;;; Auto saving to a special directory:
2919 (lambda (operation &rest args)
2920 "Returns OPERATION if it is the one to be checked."
2921 (if (equal check-file-name-operation operation)
2922 operation
2923 (let ((file-name-handler-alist fnha))
2924 (apply operation args))))))))
2925 (equal (apply operation args) operation))))
2926 3397
2927(unless (tramp-exists-file-name-handler 'make-auto-save-file-name) 3398(unless (tramp-exists-file-name-handler 'make-auto-save-file-name)
2928 (defadvice make-auto-save-file-name 3399 (defadvice make-auto-save-file-name
@@ -2982,9 +3453,7 @@ ALIST is of the form ((FROM . TO) ...)."
2982 (setq alist (cdr alist)))) 3453 (setq alist (cdr alist))))
2983 string)) 3454 string))
2984 3455
2985;; ------------------------------------------------------------ 3456;;; Compatibility functions section:
2986;; -- Compatibility functions section --
2987;; ------------------------------------------------------------
2988 3457
2989(defun tramp-read-passwd (proc &optional prompt) 3458(defun tramp-read-passwd (proc &optional prompt)
2990 "Read a password from user (compat function). 3459 "Read a password from user (compat function).
@@ -3108,11 +3577,6 @@ exiting if process is running."
3108 (tramp-compat-funcall 'set-process-query-on-exit-flag process flag) 3577 (tramp-compat-funcall 'set-process-query-on-exit-flag process flag)
3109 (tramp-compat-funcall 'process-kill-without-query process flag))) 3578 (tramp-compat-funcall 'process-kill-without-query process flag)))
3110 3579
3111
3112;; ------------------------------------------------------------
3113;; -- Kludges section --
3114;; ------------------------------------------------------------
3115
3116;; Currently (as of Emacs 20.5), the function `shell-quote-argument' 3580;; Currently (as of Emacs 20.5), the function `shell-quote-argument'
3117;; does not deal well with newline characters. Newline is replaced by 3581;; does not deal well with newline characters. Newline is replaced by
3118;; backslash newline. But if, say, the string `a backslash newline b' 3582;; backslash newline. But if, say, the string `a backslash newline b'