• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10.1/emacs-93/emacs/lisp/net/

Lines Matching +defs:file +defs:name +defs:directory

13 ;; This file is part of GNU Emacs.
26 ;; along with GNU Emacs; see the file COPYING. If not, write to the
32 ;; This package provides remote file editing, similar to ange-ftp.
37 ;; For more detailed instructions, please see the info file.
51 ;; Also see the todo list at the bottom of this file.
56 ;; There's a mailing list for this, as well. Its name is:
113 ;; Tramp only knows how to deal with `file-name-handler-alist', not
144 ;; UNC file names like "//host/share/localname".
171 ;; `directory-sep-char' is an obsolete variable in Emacs. But it is
176 (setq byte-compile-not-obsolete-var 'directory-sep-char)))
197 (when (boundp 'backup-directory-alist)
198 (defcustom tramp-backup-directory-alist nil
199 "Alist of filename patterns and backup directory names.
201 in `backup-directory-alist'. If a Tramp file is backed up, and DIRECTORY
202 is a local file name, the backup directory is prepended with Tramp file
203 name prefix \(multi-method, method, user, host\) of file.
205 \(setq tramp-backup-directory-alist backup-directory-alist\)
211 (directory :tag "Backup directory name"))))))
213 ;; XEmacs case. We cannot check for `bkup-backup-directory-info', because
217 (defcustom tramp-bkup-backup-directory-info nil
219 It has the same meaning like `bkup-backup-directory-info' from package
220 `backup-dir'. If a Tramp file is backed up, and BACKUP-DIR is a local
221 file name, the backup directory is prepended with Tramp file name prefix
222 \(multi-method, method, user, host\) of file.
224 \(setq tramp-bkup-backup-directory-info bkup-backup-directory-info\)
234 (const prepend-name)
238 (defcustom tramp-auto-save-directory nil
239 "*Put auto-save files in this directory, if set.
240 The idea is to use a local directory so that auto-saving is faster."
262 standard input or a file.
268 :type '(file :must-match t))
301 :type '(file :must-match t))
307 ;;-(defcustom tramp-file-name-quote-list
312 ;;-when sending file and directory names to the remote shell.
314 ;;-See `comint-file-name-quote-list' for details."
567 This specifies the name of the program to use for logging in to the
569 the name of rsh or a workalike program (when
571 name of telnet or a workalike (for `tramp-open-connection-telnet'),
572 or the name of su or a workalike (for `tramp-open-connection-su').
580 \"%u\" in this list is replaced by the user name, and \"%%\" can
582 \"%t\" is replaced by the temporary file name for `scp'-like methods.
584 This specifies the name of the program to use for remotely copying
585 the file; this might be the absolute filename of rcp or the name of
592 timestamp of the original file should be kept. For `rcp', use `-p', for
610 Another possibility for file transfer is inline transfer, i.e. the
611 file is passed through the same buffer used by `tramp-login-program'. In
612 this case, the file contents need to be protected since the
614 be eight-bit clean. Therefore, file contents are encoded for transit.
630 host other than `localhost' or the name of the local host."
658 Each entry in this list should be a method name as mentioned in the
673 where METHOD is the name as used in the file name, FUNCTION is the
678 user name, `%h' will be replaced with the host name, and `%n' will be
732 specifies the method to use for a file name which does not specify a
737 If the file name does not specify the user, lookup is done using the
738 empty string for the user name.
890 tilde expansion, all directory names starting with `~' will be ignored."
994 "not a regular file"
995 "is a directory"
996 "No such file or directory") t)
1012 (defcustom tramp-temp-name-prefix "tramp."
1014 If this is a relative file name (such as \"tramp.\"), it is considered
1015 relative to the directory name returned by the function
1016 `tramp-temporary-file-directory' (which see). It may also be an
1017 absolute file name; don't forget to include a prefix for the filename
1031 matching the shell file name and ARGS is a string specifying the
1036 shell from reading its init file."
1046 "*String matching the very beginning of tramp file names.
1047 Used in `tramp-make-tramp-file-name' and `tramp-make-tramp-multi-file-name'."
1053 "*Regexp matching the very beginning of tramp file names.
1070 Used in `tramp-make-tramp-file-name'."
1086 Used in `tramp-make-tramp-multi-file-name'."
1102 Used in `tramp-make-tramp-multi-file-name'."
1123 Used in `tramp-make-tramp-file-name' and `tramp-make-tramp-multi-file-name'."
1149 Used in `tramp-make-tramp-file-name' and `tramp-make-tramp-multi-file-name'."
1166 ;; File name format.
1168 (defcustom tramp-file-name-structure
1179 the tramp file name structure.
1181 The first element REGEXP is a regular expression matching a tramp file
1182 name. The regex should contain parentheses around the method name,
1183 the user name, the host name, and the file name parts.
1186 parentheses matches the method name. The third element USER is
1187 similar, but for the user name. The fourth element HOST is similar,
1188 but for the host name. The fifth element FILE is for the file name.
1192 See also `tramp-file-name-regexp'."
1194 :type '(list (regexp :tag "File name regexp")
1195 (integer :tag "Paren pair for method name")
1196 (integer :tag "Paren pair for user name ")
1197 (integer :tag "Paren pair for host name ")
1198 (integer :tag "Paren pair for file name ")))
1201 (defconst tramp-file-name-regexp-unified
1203 "Value for `tramp-file-name-regexp' for unified remoting.
1205 Tramp. See `tramp-file-name-structure-unified' for more explanations.")
1208 (defconst tramp-file-name-regexp-separate
1210 "Value for `tramp-file-name-regexp' for separate remoting.
1212 See `tramp-file-name-structure-separate' for more explanations.")
1215 (defcustom tramp-file-name-regexp
1217 tramp-file-name-regexp-unified
1218 tramp-file-name-regexp-separate)
1219 "*Regular expression matching file names handled by tramp.
1220 This regexp should match tramp file names but no other file names.
1222 `file-name-handler-alist', and that is searched sequentially. Thus,
1223 if the tramp entry appears rather early in the `file-name-handler-alist'
1227 Please note that the entry in `file-name-handler-alist' is made when
1228 this file (tramp.el) is loaded. This means that this variable must be set
1229 before loading tramp.el. Alternatively, `file-name-handler-alist' can be
1232 Also see `tramp-file-name-structure'."
1237 (defconst tramp-completion-file-name-regexp-unified
1239 "Value for `tramp-completion-file-name-regexp' for unified remoting.
1241 Tramp. See `tramp-file-name-structure-unified' for more explanations.")
1244 (defconst tramp-completion-file-name-regexp-separate
1246 "Value for `tramp-completion-file-name-regexp' for separate remoting.
1248 See `tramp-file-name-structure-separate' for more explanations.")
1251 (defcustom tramp-completion-file-name-regexp
1253 tramp-completion-file-name-regexp-unified
1254 tramp-completion-file-name-regexp-separate)
1255 "*Regular expression matching file names handled by tramp completion.
1256 This regexp should match partial tramp file names only.
1258 Please note that the entry in `file-name-handler-alist' is made when
1259 this file (tramp.el) is loaded. This means that this variable must be set
1260 before loading tramp.el. Alternatively, `file-name-handler-alist' can be
1263 Also see `tramp-file-name-structure'."
1267 (defcustom tramp-multi-file-name-structure
1275 "*Describes the file name structure of `multi' files.
1280 the file name. In this regular expression, `%s' is replaced with the
1281 value of `tramp-multi-file-name-hop-structure'. (Note: in order to
1287 paren pair which matches the method name. HOP gives the number of the
1297 :type '(list (regexp :tag "File name regexp")
1298 (integer :tag "Paren pair for method name")
1302 (defcustom tramp-multi-file-name-hop-structure
1318 (integer :tag "Paren pair for method name")
1319 (integer :tag "Paren pair for user name")
1320 (integer :tag "Paren pair for host name")))
1322 (defcustom tramp-make-multi-tramp-file-format
1330 "*Describes how to construct a `multi' file name.
1337 In PREFIX, `%%' means `%' and `%m' means the method name.
1344 The resulting file name always contains one copy of PREFIX and one
1345 copy of LOCALNAME, but there is one copy of HOP for each hop in the file
1346 name.
1349 method name, followed by all the hops, and the localname must come
1460 (let ((proc (start-process (buffer-name) (current-buffer)
1482 \(replace \"xxx\" and \"yyy\" by the remote user and host name,
1520 (defvar tramp-buffer-file-attributes nil
1524 the visited file modtime.")
1525 (make-variable-buffer-local 'tramp-buffer-file-attributes)
1542 ;; (if (fboundp 'directory-files-and-attributes)
1543 ;; (funcall 'directory-files-and-attributes
1545 ;; (tramp-temporary-file-directory)))
1548 ;; (cons x (file-attributes x)))
1549 ;; (directory-files (or (getenv "HOME")
1550 ;; (tramp-temporary-file-directory))
1632 "Remote login name for this *tramp* buffer.
1643 \(`test A -nt B' tests if file A is newer than file B.)
1647 (defvar tramp-file-exists-command nil
1648 "Command to use for checking if a file exists.
1663 ;; Perl script to implement `file-attributes' in a Lisp `read'able
1668 ;; device number set in `tramp-handle-file-attributes'
1669 (defconst tramp-perl-file-attributes "\
1703 "Perl script to produce output suitable for use with `file-attributes'
1704 on the remote file system.")
1706 (defconst tramp-perl-directory-files-and-attributes "\
1708 opendir(DIR,\".\") or printf(\"\\\"Cannot open directory $ARGV[0]: $''!''\\\"\\n\"), exit();
1753 "Perl script implementing `directory-files-attributes' as Lisp `read'able
1767 ;; "Perl program to use for encoding a file.
1768 ;; Escape sequence %s is replaced with name of Perl binary.")
1773 ;; "Perl program to use for decoding a file.
1774 ;; Escape sequence %s is replaced with name of Perl binary.")
1779 "Perl program to use for encoding a file.
1780 Escape sequence %s is replaced with name of Perl binary.
1787 "Perl program to use for decoding a file.
1788 Escape sequence %s is replaced with name of Perl binary.
1832 "Perl program to use for encoding a file.
1833 Escape sequence %s is replaced with name of Perl binary.
1878 "Perl program to use for decoding a file.
1879 Escape sequence %s is replaced with name of Perl binary.
1882 (defconst tramp-file-mode-type-map '((0 . "-") ; Normal file (SVID-v2 and XPG2)
1886 (4 . "d") ; directory
1887 (5 . "?") ; Named special file (XENIX)
1890 (8 . "-") ; regular file
1891 (9 . "n") ; network special file (HP-UX)
1897 "A list of file types returned from the `stat' system call.
1924 (let ((file-coding-system-alist '(("test" emacs-mule))))
1932 ;; handled using the normal primitives: file-name-as-directory,
1933 ;; file-name-directory, file-name-nondirectory,
1934 ;; file-name-sans-versions, get-file-buffer.
1935 (defconst tramp-file-name-handler-alist
1939 (file-name-directory . tramp-handle-file-name-directory)
1940 (file-name-nondirectory . tramp-handle-file-name-nondirectory)
1941 (file-truename . tramp-handle-file-truename)
1942 (file-exists-p . tramp-handle-file-exists-p)
1943 (file-directory-p . tramp-handle-file-directory-p)
1944 (file-executable-p . tramp-handle-file-executable-p)
1945 (file-accessible-directory-p . tramp-handle-file-accessible-directory-p)
1946 (file-readable-p . tramp-handle-file-readable-p)
1947 (file-regular-p . tramp-handle-file-regular-p)
1948 (file-symlink-p . tramp-handle-file-symlink-p)
1949 (file-writable-p . tramp-handle-file-writable-p)
1950 (file-ownership-preserved-p . tramp-handle-file-ownership-preserved-p)
1951 (file-newer-than-file-p . tramp-handle-file-newer-than-file-p)
1952 (file-attributes . tramp-handle-file-attributes)
1953 (file-modes . tramp-handle-file-modes)
1954 (directory-files . tramp-handle-directory-files)
1955 (directory-files-and-attributes . tramp-handle-directory-files-and-attributes)
1956 (file-name-all-completions . tramp-handle-file-name-all-completions)
1957 (file-name-completion . tramp-handle-file-name-completion)
1958 (add-name-to-file . tramp-handle-add-name-to-file)
1959 (copy-file . tramp-handle-copy-file)
1960 (rename-file . tramp-handle-rename-file)
1961 (set-file-modes . tramp-handle-set-file-modes)
1962 (make-directory . tramp-handle-make-directory)
1963 (delete-directory . tramp-handle-delete-directory)
1964 (delete-file . tramp-handle-delete-file)
1965 (directory-file-name . tramp-handle-directory-file-name)
1967 (process-file . tramp-handle-process-file)
1968 (insert-directory . tramp-handle-insert-directory)
1969 (expand-file-name . tramp-handle-expand-file-name)
1970 (file-local-copy . tramp-handle-file-local-copy)
1971 (file-remote-p . tramp-handle-file-remote-p)
1972 (insert-file-contents . tramp-handle-insert-file-contents)
1974 (find-backup-file-name . tramp-handle-find-backup-file-name)
1975 (make-auto-save-file-name . tramp-handle-make-auto-save-file-name)
1976 (unhandled-file-name-directory . tramp-handle-unhandled-file-name-directory)
1977 (dired-compress-file . tramp-handle-dired-compress-file)
1979 (dired-recursive-delete-directory
1980 . tramp-handle-dired-recursive-delete-directory)
1981 (set-visited-file-modtime . tramp-handle-set-visited-file-modtime)
1982 (verify-visited-file-modtime . tramp-handle-verify-visited-file-modtime))
1986 ;; Handlers for partial tramp file names. For Emacs just
1987 ;; `file-name-all-completions' is needed.
1989 (defconst tramp-completion-file-name-handler-alist
1990 '((file-name-all-completions . tramp-completion-handle-file-name-all-completions)
1991 (file-name-completion . tramp-completion-handle-file-name-completion))
1993 Used for file names matching `tramp-file-name-regexp'. Operations not
1994 mentioned here will be handled by `tramp-file-name-handler-alist' or the
1998 (defvar tramp-foreign-file-name-handler-alist
1999 ;; (identity . tramp-sh-file-name-handler) should always be the last
2001 '((identity . tramp-sh-file-name-handler))
2003 If (FUNCTION FILENAME) returns non-nil, then all I/O on that file is done by
2049 (defmacro with-parsed-tramp-file-name (filename var &rest body)
2053 Second arg VAR is a symbol. It is used as a variable name to hold
2065 `(let* ((,(or var 'v) (tramp-dissect-file-name ,filename))
2066 (,(if var (intern (concat (symbol-name var) "-multi-method")) 'multi-method)
2067 (tramp-file-name-multi-method ,(or var 'v)))
2068 (,(if var (intern (concat (symbol-name var) "-method")) 'method)
2069 (tramp-file-name-method ,(or var 'v)))
2070 (,(if var (intern (concat (symbol-name var) "-user")) 'user)
2071 (tramp-file-name-user ,(or var 'v)))
2072 (,(if var (intern (concat (symbol-name var) "-host")) 'host)
2073 (tramp-file-name-host ,(or var 'v)))
2074 (,(if var (intern (concat (symbol-name var) "-localname")) 'localname)
2075 (tramp-file-name-localname ,(or var 'v))))
2078 (put 'with-parsed-tramp-file-name 'lisp-indent-function 2)
2080 (def-edebug-spec with-parsed-tramp-file-name (form symbolp body))
2084 'emacs-lisp-mode '("\\<with-parsed-tramp-file-name\\>")))
2125 ;; Check for function and file
2127 (file-exists-p (nth 1 (car v))))
2145 If LINKNAME is a non-Tramp file, it is used verbatim as the target of
2146 the symlink. If LINKNAME is a Tramp file, only the localname component is
2149 If LINKNAME is a Tramp file and the localname component is relative, then
2153 (with-parsed-tramp-file-name linkname l
2155 (cwd (file-name-directory l-localname)))
2157 (signal 'file-error
2162 (when (file-exists-p linkname)
2170 (signal 'file-already-exists (list "File already exists" l-localname))
2171 (delete-file linkname)))
2173 ;; If FILENAME is a Tramp name, use just the localname component.
2174 (when (tramp-tramp-file-p filename)
2175 (setq filename (tramp-file-name-localname
2176 (tramp-dissect-file-name
2177 (expand-file-name filename)))))
2192 (defun tramp-handle-load (file &optional noerror nomessage nosuffix must-suffix)
2194 (unless (file-name-absolute-p file)
2195 (error "Tramp cannot `load' files without absolute file name"))
2196 (with-parsed-tramp-file-name file nil
2198 (cond ((file-exists-p (concat file ".elc"))
2199 (setq file (concat file ".elc")))
2200 ((file-exists-p (concat file ".el"))
2201 (setq file (concat file ".el")))))
2203 ;; The first condition is always true for absolute file names.
2205 (unless (or (file-name-directory file)
2206 (string-match "\\.elc?\\'" file))
2208 file)))
2210 (when (not (file-exists-p file))
2211 (error "Cannot load nonexistent file `%s'" file)))
2212 (if (not (file-exists-p file))
2215 (message "Loading %s..." file))
2216 (let ((local-copy (file-local-copy file)))
2219 (delete-file local-copy))
2221 (message "Loading %s...done" file))
2225 (defun tramp-handle-file-name-directory (file)
2226 "Like `file-name-directory' but aware of TRAMP files."
2227 ;; Everything except the last filename thing is the directory.
2228 (with-parsed-tramp-file-name file nil
2230 (tramp-make-tramp-file-name
2231 multi-method method user host (file-name-directory (or localname "")))))
2233 (defun tramp-handle-file-name-nondirectory (file)
2234 "Like `file-name-nondirectory' but aware of TRAMP files."
2235 (with-parsed-tramp-file-name file nil
2236 (file-name-nondirectory localname)))
2238 (defun tramp-handle-file-truename (filename &optional counter prev-dirs)
2239 "Like `file-truename' for tramp files."
2240 (with-parsed-tramp-file-name (expand-file-name filename) nil
2242 (localnamedir (tramp-let-maybe directory-sep-char ?/ ;for XEmacs
2243 (file-name-as-directory localname)))
2256 10 "Finding true name for `%s'" filename)
2266 (nth 0 (file-attributes
2267 (tramp-make-tramp-file-name
2287 (when (file-name-absolute-p symlink-target)
2292 (when (tramp-tramp-file-p symlink-target)
2293 (with-parsed-tramp-file-name symlink-target sym
2303 ;; It's a file.
2318 10 "True name of `%s' is `%s'" filename result)
2319 (tramp-make-tramp-file-name
2324 (defun tramp-handle-file-exists-p (filename)
2325 "Like `file-exists-p' for tramp files."
2326 (with-parsed-tramp-file-name filename nil
2331 (tramp-get-file-exists-command multi-method method user host)
2334 ;; Devices must distinguish physical file systems. The device numbers
2345 (defun tramp-handle-file-attributes (filename &optional id-format)
2346 "Like `file-attributes' for tramp files."
2347 (when (file-exists-p filename)
2348 ;; file exists, find out stuff
2350 (with-parsed-tramp-file-name filename nil
2352 (tramp-convert-file-attributes
2355 (tramp-handle-file-attributes-with-perl multi-method method user host
2357 (tramp-handle-file-attributes-with-ls multi-method method user host
2360 (defun tramp-handle-file-attributes-with-ls
2362 "Implement `file-attributes' for tramp files using the ls(1) command."
2367 "file attributes with ls: %s"
2368 (tramp-make-tramp-file-name
2394 ;; ... file mode flags
2395 (setq res-filemodes (symbol-name (read (current-buffer))))
2406 ;; From the file modes, figure out other stuff.
2409 ;; if symlink, find out file name pointed to
2417 ;; 0. t for directory, string (name linked to) for symbolic
2420 ;; 1. Number of links to file.
2436 ;; 9. t iff file's gid would change if file were deleted and
2437 ;; recreated. Will be set in `tramp-convert-file-attributes'
2445 (defun tramp-handle-file-attributes-with-perl
2447 "Implement `file-attributes' for tramp files using a Perl script."
2449 "file attributes with perl: %s"
2450 (tramp-make-tramp-file-name
2453 tramp-perl-file-attributes
2461 (defun tramp-handle-set-visited-file-modtime (&optional time-list)
2462 "Like `set-visited-file-modtime' for tramp files."
2463 (unless (buffer-file-name)
2464 (error "Can't set-visited-file-modtime: buffer `%s' not visiting a file"
2465 (buffer-name)))
2467 (tramp-run-real-handler 'set-visited-file-modtime (list time-list))
2468 (let ((f (buffer-file-name))
2470 (with-parsed-tramp-file-name f nil
2471 (let* ((attr (file-attributes f))
2472 ;; '(-1 65535) means file doesn't exists yet.
2477 ;; `tramp-handle-file-attributes-with-ls'.
2479 (tramp-run-real-handler 'set-visited-file-modtime (list modtime))
2489 (setq tramp-buffer-file-attributes attr))
2497 ;; `tramp-handle-set-visited-file-modtime'.
2498 (defun tramp-handle-verify-visited-file-modtime (buf)
2499 "Like `verify-visited-file-modtime' for tramp files.
2500 At the time `verify-visited-file-modtime' calls this function, we
2501 already know that the buffer is visiting a file and that
2502 `visited-file-modtime' does not return 0. Do not call this
2506 ;; There is no file visiting the buffer, or the buffer has no
2508 (if (or (not (buffer-file-name))
2509 (eq (visited-file-modtime) 0))
2511 (let ((f (buffer-file-name)))
2512 (with-parsed-tramp-file-name f nil
2513 (let* ((attr (file-attributes f))
2515 (mt (visited-file-modtime)))
2518 ;; file exists, and has a known modtime.
2524 ;; return values of `visited-file-modtime'.
2540 (equal tramp-buffer-file-attributes attr))
2541 ;; If file does not exist, say it is not modified
2545 (defun tramp-handle-set-file-modes (filename mode)
2546 "Like `set-file-modes' for tramp files."
2547 (with-parsed-tramp-file-name filename nil
2554 (signal 'file-error
2557 "error while changing file's mode"
2562 (defun tramp-handle-file-executable-p (filename)
2563 "Like `file-executable-p' for tramp files."
2564 (with-parsed-tramp-file-name filename nil
2567 (defun tramp-handle-file-readable-p (filename)
2568 "Like `file-readable-p' for tramp files."
2569 (with-parsed-tramp-file-name filename nil
2572 (defun tramp-handle-file-accessible-directory-p (filename)
2573 "Like `file-accessible-directory-p' for tramp files."
2574 (with-parsed-tramp-file-name filename nil
2584 (defun tramp-handle-file-newer-than-file-p (file1 file2)
2585 "Like `file-newer-than-file-p' for tramp files."
2586 (cond ((not (file-exists-p file1))
2588 ((not (file-exists-p file2))
2596 (let ((fa1 (file-attributes file1))
2597 (fa2 (file-attributes file2)))
2606 (unless (and (tramp-tramp-file-p file1)
2607 (tramp-tramp-file-p file2))
2609 'file-error
2611 "Cannot check if Tramp file is newer than non-Tramp file"
2613 (with-parsed-tramp-file-name file1 v1
2614 (with-parsed-tramp-file-name file2 v2
2619 (signal 'file-error
2622 (unless (and (tramp-tramp-file-p file1)
2623 (tramp-tramp-file-p file2))
2624 (signal 'file-error
2635 (defun tramp-handle-file-modes (filename)
2636 "Like `file-modes' for tramp files."
2637 (with-parsed-tramp-file-name filename nil
2638 (when (file-exists-p filename)
2640 (nth 8 (file-attributes filename))))))
2642 (defun tramp-handle-file-directory-p (filename)
2643 "Like `file-directory-p' for tramp files."
2652 (with-parsed-tramp-file-name filename nil
2661 (defun tramp-handle-file-regular-p (filename)
2662 "Like `file-regular-p' for tramp files."
2663 (with-parsed-tramp-file-name filename nil
2664 (and (file-exists-p filename)
2665 (eq ?- (aref (nth 8 (file-attributes filename)) 0)))))
2667 (defun tramp-handle-file-symlink-p (filename)
2668 "Like `file-symlink-p' for tramp files."
2669 (with-parsed-tramp-file-name filename nil
2670 (let ((x (car (file-attributes filename))))
2672 ;; When Tramp is running on VMS, then `file-name-absolute-p'
2674 (if (file-name-absolute-p x)
2675 (tramp-make-tramp-file-name
2679 (defun tramp-handle-file-writable-p (filename)
2680 "Like `file-writable-p' for tramp files."
2681 (with-parsed-tramp-file-name filename nil
2682 (if (file-exists-p filename)
2685 ;; If file doesn't exist, check if directory is writable.
2687 "-d" (file-name-directory filename)))
2689 "-w" (file-name-directory filename)))))))
2691 (defun tramp-handle-file-ownership-preserved-p (filename)
2692 "Like `file-ownership-preserved-p' for tramp files."
2693 (with-parsed-tramp-file-name filename nil
2694 (let ((attributes (file-attributes filename)))
2695 ;; Return t if the file doesn't exist, since it's true that no
2701 ;; Other file name ops.
2704 ;; (defun tramp-handle-directory-file-name (directory)
2705 ;; "Like `directory-file-name' for tramp files."
2706 ;; (if (and (eq (aref directory (- (length directory) 1)) ?/)
2707 ;; (not (eq (aref directory (- (length directory) 2)) ?:)))
2708 ;; (substring directory 0 (- (length directory) 1))
2709 ;; directory))
2712 ;; (defun tramp-handle-directory-file-name (directory)
2713 ;; "Like `directory-file-name' for tramp files."
2714 ;; (with-parsed-tramp-file-name directory nil
2715 ;; (let ((directory-length-1 (1- (length directory))))
2717 ;; (if (and (eq (aref directory directory-length-1) ?/)
2718 ;; (eq (string-match tramp-file-name-regexp directory) 0)
2719 ;; (/= (match-end 0) directory-length-1))
2720 ;; (substring directory 0 directory-length-1)
2721 ;; directory)))))
2723 (defun tramp-handle-directory-file-name (directory)
2724 "Like `directory-file-name' for tramp files."
2729 (with-parsed-tramp-file-name directory nil
2733 (substring directory 0 -1)
2734 directory)))
2738 (defun tramp-handle-directory-files (directory
2740 "Like `directory-files' for tramp files."
2741 (with-parsed-tramp-file-name directory nil
2748 'file-error
2749 "tramp-handle-directory-files: couldn't `cd %s'"
2762 (push (concat (file-name-as-directory directory)
2771 ;; tramp-handle-file-name-all-completions.
2780 (when (file-regular-p item)
2785 (when (file-directory-p item)
2789 (defun tramp-handle-directory-files-and-attributes
2790 (directory &optional full match nosort id-format)
2791 "Like `directory-files-and-attributes' for tramp files."
2792 (when (tramp-handle-file-exists-p directory)
2794 (setq directory (tramp-handle-expand-file-name directory))
2795 (with-parsed-tramp-file-name directory nil
2797 tramp-perl-directory-files-and-attributes
2816 (tramp-convert-file-attributes multi-method method user host
2818 ;; If FULL, make file name absolute
2819 (when full (setcar l (concat directory "/" (car l)))))))
2826 ;; directories), and `find . -type d \! -name . -prune' to get a list
2828 (defun tramp-handle-file-name-all-completions (filename directory)
2829 "Like `file-name-all-completions' for tramp files."
2830 (with-parsed-tramp-file-name directory nil
2838 nil 'file-error
2839 "tramp-handle-file-name-all-completions: Couldn't `cd %s'"
2874 (defun tramp-handle-file-name-completion
2875 (filename directory &optional predicate)
2876 "Like `file-name-completion' for tramp files."
2877 (unless (tramp-tramp-file-p directory)
2879 "tramp-handle-file-name-completion invoked on non-tramp directory `%s'"
2880 directory))
2883 (mapcar 'list (file-name-all-completions filename directory))
2885 (lambda (x) (funcall predicate (expand-file-name (car x) directory))))))
2889 (defun tramp-handle-add-name-to-file
2891 "Like `add-name-to-file' for tramp files."
2892 (with-parsed-tramp-file-name filename v1
2893 (with-parsed-tramp-file-name newname v2
2901 (error "add-name-to-file: %s"
2904 (file-exists-p newname)
2908 "File %s already exists; make it a new name anyway? "
2910 (error "add-name-to-file: file %s already exists" newname))
2915 nil 'file-error
2916 "error with add-name-to-file, see buffer `%s' for details"
2917 (buffer-name))))))
2919 (defun tramp-handle-copy-file
2921 "Like `copy-file' for tramp files."
2922 ;; Check if both files are local -- invoke normal copy-file.
2924 (setq filename (expand-file-name filename))
2925 (setq newname (expand-file-name newname))
2926 ;; At least one file a tramp file?
2927 (if (or (tramp-tramp-file-p filename)
2928 (tramp-tramp-file-p newname))
2929 (tramp-do-copy-or-rename-file
2932 'copy-file
2935 (defun tramp-handle-rename-file
2937 "Like `rename-file' for tramp files."
2938 ;; Check if both files are local -- invoke normal rename-file.
2940 (setq filename (expand-file-name filename))
2941 (setq newname (expand-file-name newname))
2942 ;; At least one file a tramp file?
2943 (if (or (tramp-tramp-file-p filename)
2944 (tramp-tramp-file-p newname))
2945 (tramp-do-copy-or-rename-file
2947 (tramp-run-real-handler 'rename-file
2950 (defun tramp-do-copy-or-rename-file
2952 "Copy or rename a remote file.
2954 FILENAME specifies the file to copy or rename, NEWNAME is the name of
2955 the new file (for copy) or the new name of the file (for rename).
2960 This function is invoked by `tramp-handle-copy-file' and
2961 `tramp-handle-rename-file'. It is an error if OP is neither of `copy'
2962 and `rename'. FILENAME and NEWNAME must be absolute file names."
2966 (when (file-exists-p newname)
2967 (signal 'file-already-exists
2969 (let ((t1 (tramp-tramp-file-p filename))
2970 (t2 (tramp-tramp-file-p newname))
2975 ;; We cannot invoke `with-parsed-tramp-file-name';
2976 ;; it fails if the file isn't a Tramp file name.
2978 (with-parsed-tramp-file-name filename l
2986 (with-parsed-tramp-file-name newname l
3005 (tramp-do-copy-or-rename-file-directly
3011 ;; default-directory should point to a local
3012 ;; directory if we want to invoke rcp.
3020 (tramp-do-copy-or-rename-file-out-of-band
3023 ;; file first. If the operation was `rename', we go
3024 ;; back and delete the original file (if the copy was
3027 ;; source file into it, then write out the buffer to
3028 ;; the target file. The advantage is that it doesn't
3030 ;; source and target file.
3032 (tramp-do-copy-or-rename-file-via-buffer
3035 ;; One file is a Tramp file, the other one is local.
3037 ;; If the Tramp file has an out-of-band method, the corresponding
3045 (tramp-do-copy-or-rename-file-out-of-band
3048 (tramp-do-copy-or-rename-file-via-buffer
3052 ;; One of them must be a Tramp file.
3055 (defun tramp-do-copy-or-rename-file-via-buffer (op filename newname keep-date)
3056 "Use an Emacs buffer to copy or rename a file.
3058 FILENAME is the source file, NEWNAME the target file.
3061 (modtime (nth 5 (file-attributes filename))))
3064 1 (concat "Warning: cannot preserve file time stamp"
3068 (insert-file-contents-literally filename)
3069 ;; We don't want the target file to be compressed, so we let-bind
3080 (set-file-modes newname (file-modes filename)))
3081 ;; If the operation was `rename', delete the original file.
3083 (delete-file filename))))
3085 (defun tramp-do-copy-or-rename-file-directly
3116 (signal 'file-error
3118 (buffer-name)))))
3123 (set-file-modes
3124 (tramp-make-tramp-file-name multi-method method user host localname2)
3125 (file-modes
3126 (tramp-make-tramp-file-name
3129 (defun tramp-do-copy-or-rename-file-out-of-band (op filename newname keep-date)
3131 One of FILENAME and NEWNAME must be a Tramp name, the other must
3133 (let ((t1 (tramp-tramp-file-p filename))
3134 (t2 (tramp-tramp-file-p newname))
3141 ;; We cannot invoke `with-parsed-tramp-file-name';
3142 ;; it fails if the file isn't a Tramp file name.
3144 (with-parsed-tramp-file-name filename l
3164 (with-parsed-tramp-file-name newname l
3191 (tramp-make-copy-program-file-name
3201 (tramp-make-copy-program-file-name
3210 x `((?t . ,(format "/tmp/%s" tramp-temp-name-prefix)))))
3229 (tramp-buffer-name multi-method method user host)))
3246 ;; Use rcp-like program for file transfer.
3248 (let* ((default-directory
3249 (if (and (stringp default-directory)
3250 (file-accessible-directory-p default-directory))
3251 default-directory
3252 (tramp-temporary-file-directory)))
3253 (p (apply 'start-process (buffer-name trampbuf) trampbuf
3263 (set-file-modes newname (file-modes filename))))
3265 ;; If the operation was `rename', delete the original file.
3267 (delete-file filename))))
3270 (defun tramp-handle-make-directory (dir &optional parents)
3271 "Like `make-directory' for tramp files."
3272 (setq dir (expand-file-name dir))
3273 (with-parsed-tramp-file-name dir nil
3280 nil 'file-error
3281 "Couldn't make directory %s" dir))))
3284 (defun tramp-handle-delete-directory (directory)
3285 "Like `delete-directory' for tramp files."
3286 (setq directory (expand-file-name directory))
3287 (with-parsed-tramp-file-name directory nil
3295 (defun tramp-handle-delete-file (filename)
3296 "Like `delete-file' for tramp files."
3297 (setq filename (expand-file-name filename))
3298 (with-parsed-tramp-file-name filename nil
3304 (signal 'file-error "Couldn't delete Tramp file")))))
3310 (defun tramp-handle-dired-recursive-delete-directory (filename)
3311 "Recursively delete the directory given.
3312 This is like `dired-recursive-delete-directory' for tramp files."
3313 (with-parsed-tramp-file-name filename nil
3316 (or (file-exists-p filename)
3318 'file-error
3319 (list "Removing old file name" "no such directory" filename)))
3327 (and (file-exists-p filename)
3332 (with-parsed-tramp-file-name default-directory nil
3337 nil 'file-error
3347 ;; `expand-file' and alike.
3358 (defun tramp-handle-dired-compress-file (file &rest ok-flag)
3359 "Like `dired-compress-file' for tramp files."
3362 (with-parsed-tramp-file-name file nil
3367 (symbol-value 'dired-compress-file-suffixes)
3369 ;; transformed into `dired-compress-file-suffixes' structure.
3377 ;; See if any suffix rule matches this file name.
3384 (cond ((file-symlink-p file)
3388 (message "Uncompressing %s..." file)
3392 (message "Uncompressing %s...done" file)
3393 ;; `dired-remove-file' is not defined in XEmacs
3394 (funcall (symbol-function 'dired-remove-file) file)
3395 (string-match (car suffix) file)
3396 (concat (substring file 0 (match-beginning 0)))))
3398 ;; We don't recognize the file as compressed, so compress it.
3400 (message "Compressing %s..." file)
3404 (message "Compressing %s...done" file)
3405 ;; `dired-remove-file' is not defined in XEmacs
3406 (funcall (symbol-function 'dired-remove-file) file)
3407 (cond ((file-exists-p (concat file ".gz"))
3408 (concat file ".gz"))
3409 ((file-exists-p (concat file ".z"))
3410 (concat file ".z"))
3426 (defun tramp-handle-insert-directory
3427 (filename switches &optional wildcard full-directory-p)
3428 "Like `insert-directory' for tramp files."
3429 (if (and (boundp 'ls-lisp-use-insert-directory-program)
3430 (not (symbol-value 'ls-lisp-use-insert-directory-program)))
3431 (tramp-run-real-handler 'insert-directory
3432 (list filename switches wildcard full-directory-p))
3438 (setq filename (expand-file-name filename))
3439 (with-parsed-tramp-file-name filename nil
3442 "Inserting directory `ls %s %s', wildcard %s, fulldir %s"
3444 (if full-directory-p "yes" "no"))
3446 (setq wildcard (file-name-nondirectory localname))
3447 (setq localname (file-name-directory localname)))
3450 (unless full-directory-p
3455 ;; If `full-directory-p', we just say `ls -l FILENAME'.
3456 ;; Else we chdir to the parent directory, then say `ls -ld BASENAME'.
3457 (if full-directory-p
3469 (file-name-directory localname)))
3470 nil 'file-error
3472 (tramp-shell-quote-argument (file-name-directory localname)))
3480 (if (zerop (length (file-name-nondirectory localname)))
3483 (file-name-nondirectory localname)))))))
3493 ;; `expand-file' and alike.
3524 (defun tramp-handle-unhandled-file-name-directory (filename)
3525 "Like `unhandled-file-name-directory' for tramp files."
3526 (with-parsed-tramp-file-name filename nil
3527 (expand-file-name "~/")))
3529 ;; Canonicalization of file names.
3531 (defun tramp-drop-volume-letter (name)
3532 "Cut off unnecessary drive letter from file NAME.
3533 The function `tramp-handle-expand-file-name' calls `expand-file-name'
3534 locally on a remote file name. When the local system is a W32 system
3536 letter into the file name. This function removes it.
3539 (if (and (> (length name) 1)
3540 (char-equal (aref name 1) ?:)
3541 (let ((c1 (aref name 0)))
3544 (substring name 2)
3545 name))
3547 (defun tramp-handle-expand-file-name (name &optional dir)
3548 "Like `expand-file-name' for tramp files.
3552 (setq dir (or dir default-directory "/"))
3554 (unless (file-name-absolute-p name)
3555 (setq name (concat (file-name-as-directory dir) name)))
3556 ;; If NAME is not a tramp file, run the real handler
3557 (if (not (tramp-tramp-file-p name))
3558 (tramp-run-real-handler 'expand-file-name
3559 (list name nil))
3561 (with-parsed-tramp-file-name name nil
3562 (unless (file-name-absolute-p localname)
3573 ;; expanded to the local user home directory but to the
3574 ;; root home directory. On the other hand, using always
3575 ;; the default user name for tilde expansion is not
3577 ;; use a user name from the config file.
3599 ;; No tilde characters in file name, do normal
3600 ;; expand-file-name (this does "/./" and "/../"). We bind
3601 ;; directory-sep-char here for XEmacs on Windows, which would
3602 ;; otherwise use backslash. `default-directory' is bound to
3605 (tramp-let-maybe directory-sep-char ?/
3606 (let ((default-directory "/"))
3607 (tramp-make-tramp-file-name
3611 (tramp-run-real-handler 'expand-file-name
3614 ;; old version follows. it uses ".." to cross file handler
3617 ;; ;; the case, then we return a local name instead of a remote name.
3619 ;; (expand-file-name (substring localname 3))
3620 ;; ;; No tilde characters in file name, do normal
3621 ;; ;; expand-file-name (this does "/./" and "/../"). We bind
3622 ;; ;; directory-sep-char here for XEmacs on Windows, which
3624 ;; (let ((directory-sep-char ?/))
3625 ;; (tramp-make-tramp-file-name
3628 ;; (tramp-run-real-handler 'expand-file-name
3639 This is necessary for handling DISPLAY of `process-file'.")
3646 ;; for `find-grep-dired' and `find-name-dired' in Emacs 22.
3647 (if (tramp-tramp-file-p default-directory)
3648 (with-parsed-tramp-file-name default-directory nil
3670 tramp-async-proc (start-process (buffer-name output-buffer)
3676 nil 'file-error
3713 ;; `expand-file' and alike.
3756 (message "tramp-handle-shell-command called with non-tramp directory: `%s'"
3757 default-directory)
3761 (defun tramp-handle-process-file (program &optional infile buffer display &rest args)
3762 "Like `process-file' for Tramp files."
3763 (when infile (error "Implementation does not handle input from file"))
3774 (defsubst tramp-make-temp-file (filename)
3776 (funcall (if (fboundp 'make-temp-file) 'make-temp-file 'make-temp-name)
3777 (expand-file-name tramp-temp-name-prefix
3778 (tramp-temporary-file-directory)))
3779 (file-name-extension filename t)))
3781 (defun tramp-handle-file-local-copy (filename)
3782 "Like `file-local-copy' for tramp files."
3783 (with-parsed-tramp-file-name filename nil
3796 (unless (file-exists-p filename)
3797 (error "Cannot make local copy of non-existing file `%s'"
3799 (setq tmpfil (tramp-make-temp-file filename))
3802 ;; `copy-file' handles out-of-band methods
3803 (copy-file filename tmpfil t t))
3806 ;; Use inline encoding for file transfer.
3811 (tramp-message 5 "Encoding remote file %s..." filename)
3815 nil 'file-error
3816 "Encoding remote file failed, see buffer `%s' for details"
3822 (tramp-message 5 "Decoding remote file %s..." filename)
3837 6 "Decoding remote file %s with function %s..."
3851 (let ((tmpfil2 (tramp-make-temp-file filename)))
3854 6 "Decoding remote file %s with command %s..."
3858 (delete-file tmpfil2)))
3861 5 "Decoding remote file %s...done" filename)
3863 (set-file-modes tmpfil (file-modes filename))))
3868 (defun tramp-handle-file-remote-p (filename)
3869 "Like `file-remote-p' for tramp files."
3870 (when (tramp-tramp-file-p filename)
3871 (with-parsed-tramp-file-name filename nil
3872 (make-tramp-file-name
3879 (defun tramp-handle-insert-file-contents
3881 "Like `insert-file-contents' for tramp files."
3883 (setq filename (expand-file-name filename))
3884 (with-parsed-tramp-file-name filename nil
3885 (if (not (file-exists-p filename))
3888 (setq buffer-file-name filename)
3889 (set-visited-file-modtime)
3891 (signal 'file-error
3893 (list (expand-file-name filename) 0))
3894 ;; `insert-file-contents-literally' takes care to avoid calling
3895 ;; jka-compr. By let-binding inhibit-file-name-operation, we
3896 ;; propagate that care to the file-local-copy operation.
3898 (let ((inhibit-file-name-operation
3899 (when (eq inhibit-file-name-operation
3900 'insert-file-contents)
3901 'file-local-copy)))
3902 (file-local-copy filename)))
3905 (setq buffer-file-name filename)
3906 (set-visited-file-modtime)
3910 9 "Inserting local temp file `%s'..." local-copy)
3911 (setq result (insert-file-contents local-copy nil beg end replace))
3917 9 "Inserting local temp file `%s'...done" local-copy)
3918 (delete-file local-copy)
3921 (list (expand-file-name filename)
3925 (defun tramp-handle-find-backup-file-name (filename)
3926 "Like `find-backup-file-name' for tramp files."
3927 (with-parsed-tramp-file-name filename nil
3930 (let ((backup-directory-alist
3932 (when (boundp 'backup-directory-alist)
3933 (if (boundp 'tramp-backup-directory-alist)
3939 (file-name-absolute-p (cdr x))
3940 (not (tramp-file-name-p (cdr x))))
3941 (tramp-make-tramp-file-name
3944 (symbol-value 'tramp-backup-directory-alist))
3945 (symbol-value 'backup-directory-alist))))
3947 (bkup-backup-directory-info
3949 (when (boundp 'bkup-backup-directory-info)
3950 (if (boundp 'tramp-bkup-backup-directory-info)
3957 (file-name-absolute-p (car (cdr x)))
3958 (not (tramp-file-name-p (car (cdr x)))))
3959 (tramp-make-tramp-file-name
3963 (symbol-value 'tramp-bkup-backup-directory-info))
3964 (symbol-value 'bkup-backup-directory-info)))))
3966 (tramp-run-real-handler 'find-backup-file-name (list filename)))))
3968 (defun tramp-handle-make-auto-save-file-name ()
3969 "Like `make-auto-save-file-name' for tramp files.
3970 Returns a file name in `tramp-auto-save-directory' for autosaving this file."
3971 (let ((tramp-auto-save-directory tramp-auto-save-directory))
3972 ;; File name must be unique. This is ensured with Emacs 22 (see
3973 ;; UNIQUIFY element of `auto-save-file-name-transforms'); but for
3975 (when (boundp 'auto-save-file-name-transforms)
3978 (when (and (string-match (car x) buffer-file-name)
3980 (setq tramp-auto-save-directory
3981 (or tramp-auto-save-directory temporary-file-directory))))
3982 (symbol-value 'auto-save-file-name-transforms)))
3983 ;; Create directory.
3984 (when tramp-auto-save-directory
3985 (unless (file-exists-p tramp-auto-save-directory)
3986 (make-directory tramp-auto-save-directory t)))
3988 ;; file name we make sure that jka-compr isn't used for the
3989 ;; auto-save file.
3990 (let ((buffer-file-name
3991 (if tramp-auto-save-directory
3992 (expand-file-name
4000 (buffer-file-name))
4001 tramp-auto-save-directory)
4002 (buffer-file-name))))
4003 ;; Run plain `make-auto-save-file-name'. There might be an advice when
4004 ;; it is not a magic file name operation (since Emacs 22).
4006 (if (not (ad-is-active 'make-auto-save-file-name))
4008 'make-auto-save-file-name nil)
4010 (ad-deactivate 'make-auto-save-file-name)
4013 'make-auto-save-file-name nil)
4014 (ad-activate 'make-auto-save-file-name))))))
4022 (error "Cannot append to file using tramp (`%s')" filename))
4023 (setq filename (expand-file-name filename))
4025 ;; file locking, and it does not appear to be a problem to ignore it.
4028 ;; (setq lockname (expand-file-name lockname)))
4035 confirm (file-exists-p filename))
4039 (with-parsed-tramp-file-name filename nil
4046 (modes (file-modes filename))
4048 ;; after writing the tmp file. At the end of the function,
4055 ;; Write region into a tmp file. This isn't really needed if we
4058 (setq tmpfil (tramp-make-temp-file filename))
4059 ;; Set current buffer. If connection wasn't open, `file-modes' has
4062 ;; We say `no-message' here because we don't want the visited file
4063 ;; modtime data to be clobbered from the temp file. We call
4064 ;; `set-visited-file-modtime' ourselves later on.
4073 ;; The permissions of the temporary file should be set. If
4075 ;; the backup file. This case `save-buffer' handles
4077 (when modes (set-file-modes tmpfil modes))
4079 ;; file transfer. First, we check whether the method uses an rcp
4083 ;; encoding the contents of the tmp file.
4085 ;; `copy-file' handles out-of-band methods
4086 (copy-file tmpfil filename t t))
4089 ;; Use inline file transfer
4090 (let ((tmpbuf (get-buffer-create " *tramp file transfer*")))
4103 (symbol-name loc-enc))
4104 (insert-file-contents-literally tmpfil)
4108 ;; satisfied, it tries to write to a local file
4109 ;; in default-directory, but at this point,
4110 ;; default-directory is remote.
4112 ;; files, it seems.) The file in question is a
4113 ;; tmp file anyway.
4114 (let ((default-directory
4115 (tramp-temporary-file-directory)))
4130 ;; writes to remote file. Because this happens on the
4134 5 "Decoding region into remote file %s..." filename)
4158 multi-method method user host nil nil 'file-error
4162 (tramp-message 5 "Decoding region into remote file %s...done"
4170 (delete-file tmpfil)
4175 (set-visited-file-modtime
4177 ;; from (buffer-file-name), f.e. if `file-precious-flag' is set.
4178 (nth 5 (file-attributes filename))))
4189 ;; TRAMP file name) it is needed to disable efs as well as tramp for the
4192 ;; Other than that, this is the canon file-handler code that the doco
4205 ;; "Invoke normal file name handler for OPERATION.
4209 ;; (let ((inhibit-file-name-handlers
4210 ;; (list 'tramp-file-name-handler
4211 ;; 'efs-file-handler-function
4213 ;; (and (eq inhibit-file-name-operation operation)
4214 ;; inhibit-file-name-handlers)))
4215 ;; (inhibit-file-name-operation operation))
4220 "Invoke normal file name handler for OPERATION.
4223 (let* ((inhibit-file-name-handlers
4224 `(tramp-file-name-handler
4225 tramp-completion-file-name-handler
4226 cygwin-mount-name-hook-function
4229 ,(and (eq inhibit-file-name-operation operation)
4230 inhibit-file-name-handlers)))
4231 (inhibit-file-name-operation operation))
4234 ;; This function is used from `tramp-completion-file-name-handler' functions
4240 "Invoke `tramp-file-name-handler' for OPERATION.
4243 (let* ((inhibit-file-name-handlers
4244 `(tramp-completion-file-name-handler
4245 cygwin-mount-name-hook-function
4248 ,(and (eq inhibit-file-name-operation operation)
4249 inhibit-file-name-handlers)))
4250 (inhibit-file-name-operation operation))
4253 ;; We handle here all file primitives. Most of them have the file
4254 ;; name as first parameter; nevertheless we check for them explicitly
4258 ;; ease the life if `file-name-handler-alist' would support a decision
4260 (defun tramp-file-name-for-operation (operation &rest args)
4261 "Return file name related to OPERATION file primitive.
4266 (list 'access-file 'byte-compiler-base-file-name 'delete-directory
4267 'delete-file 'diff-latest-backup-file 'directory-file-name
4268 'directory-files 'directory-files-and-attributes
4269 'dired-compress-file 'dired-uncache
4270 'file-accessible-directory-p 'file-attributes
4271 'file-directory-p 'file-executable-p 'file-exists-p
4272 'file-local-copy 'file-remote-p 'file-modes
4273 'file-name-as-directory 'file-name-directory
4274 'file-name-nondirectory 'file-name-sans-versions
4275 'file-ownership-preserved-p 'file-readable-p
4276 'file-regular-p 'file-symlink-p 'file-truename
4277 'file-writable-p 'find-backup-file-name 'find-file-noselect
4278 'get-file-buffer 'insert-directory 'insert-file-contents
4279 'load 'make-directory 'make-directory-internal
4280 'set-file-modes 'substitute-in-file-name
4281 'unhandled-file-name-directory 'vc-registered
4283 'abbreviate-file-name 'create-file-buffer
4284 'dired-file-modtime 'dired-make-compressed-filename
4285 'dired-recursive-delete-directory 'dired-set-file-modtime
4286 'dired-shell-unhandle-file-name 'dired-uucode-file
4287 'insert-file-contents-literally 'recover-file
4289 (if (file-name-absolute-p (nth 0 args))
4291 (expand-file-name (nth 0 args))))
4294 (list 'add-name-to-file 'copy-file 'expand-file-name
4295 'file-name-all-completions 'file-name-completion
4296 'file-newer-than-file-p 'make-symbolic-link 'rename-file
4302 ((string-match tramp-file-name-regexp (nth 0 args)) (nth 0 args))
4303 ((string-match tramp-file-name-regexp (nth 1 args)) (nth 1 args))
4304 (t (buffer-file-name (current-buffer))))))
4310 (list 'make-auto-save-file-name
4311 'set-visited-file-modtime 'verify-visited-file-modtime
4314 (buffer-file-name
4322 'process-file
4324 'dired-print-file 'dired-shell-call-process))
4325 default-directory)
4326 ; unknown file primitive
4327 (t (error "unknown file I/O primitive: %s" operation))))
4329 (defun tramp-find-foreign-file-name-handler (filename)
4330 "Return foreign file name handler if exists."
4331 (when (tramp-tramp-file-p filename)
4334 (handler-alist tramp-foreign-file-name-handler-alist))
4345 (defun tramp-file-name-handler (operation &rest args)
4346 "Invoke Tramp file name handler.
4347 Falls back to normal file name handler if no tramp file name handler exists."
4351 (let* ((filename (apply 'tramp-file-name-for-operation operation args))
4353 (foreign (tramp-find-foreign-file-name-handler filename)))
4354 (with-parsed-tramp-file-name filename nil
4358 ((and completion (memq operation '(expand-file-name)))
4361 (memq operation '(file-exists-p file-directory-p)))
4378 ;; processing of a single file operation, so we need to allow
4396 (defun tramp-sh-file-name-handler (operation &rest args)
4397 "Invoke remote-shell Tramp file name handler.
4398 Fall back to normal file name handler if no Tramp handler exists."
4400 (signal 'file-error "Forbidden reentrant call of Tramp"))
4407 (let ((fn (assoc operation tramp-file-name-handler-alist)))
4414 (progn (defun tramp-completion-file-name-handler (operation &rest args)
4415 "Invoke tramp file name completion handler.
4416 Falls back to normal file name handler if no tramp file name handler exists."
4419 (let ((fn (assoc operation tramp-completion-file-name-handler-alist)))
4425 (defsubst tramp-register-file-name-handler ()
4426 "Add tramp file name handler to `file-name-handler-alist'."
4427 (add-to-list 'file-name-handler-alist
4428 (cons tramp-file-name-regexp 'tramp-file-name-handler))
4430 ;; `file-name-handler-alist'.
4431 (let ((jka (rassoc 'jka-compr-handler file-name-handler-alist)))
4433 (setq file-name-handler-alist
4434 (cons jka (delete jka file-name-handler-alist))))))
4437 (defsubst tramp-register-completion-file-name-handler ()
4438 "Add tramp completion file name handler to `file-name-handler-alist'."
4441 ;; user/host name completion shall be bound to `partial-completion-mode'.
4445 (add-to-list 'file-name-handler-alist
4446 (cons tramp-completion-file-name-regexp
4447 'tramp-completion-file-name-handler))
4448 (put 'tramp-completion-file-name-handler 'safe-magic t))
4450 ;; `file-name-handler-alist'.
4451 (let ((jka (rassoc 'jka-compr-handler file-name-handler-alist)))
4453 (setq file-name-handler-alist
4454 (cons jka (delete jka file-name-handler-alist))))))
4456 ;; `tramp-file-name-handler' must be registered before evaluation of
4459 ;;;###autoload(tramp-register-file-name-handler)
4462 ;; `tramp-completion-file-name-handler' will be delayed.
4465 ;;;###autoload '(lambda () (tramp-register-completion-file-name-handler)))
4466 (tramp-register-file-name-handler)
4467 (tramp-register-completion-file-name-handler)
4470 (defun tramp-unload-file-name-handlers ()
4471 (setq file-name-handler-alist
4472 (delete (rassoc 'tramp-file-name-handler
4473 file-name-handler-alist)
4474 (delete (rassoc 'tramp-completion-file-name-handler
4475 file-name-handler-alist)
4476 file-name-handler-alist))))
4478 (add-hook 'tramp-unload-hook 'tramp-unload-file-name-handlers)
4486 (defun tramp-handle-expand-many-files (name)
4488 (with-parsed-tramp-file-name name nil
4490 (if (or (string-match "\\*" name)
4491 (string-match "\\?" name)
4492 (string-match "\\[.*\\]" name))
4496 ;; in the file name, but since the echo command is going to
4497 ;; break anyway when there are spaces in the file names, we
4499 ;;-(let ((comint-file-name-quote-list
4500 ;;- (set-difference tramp-file-name-quote-list
4524 (tramp-make-tramp-file-name multi-method method
4527 (list (expand-file-name name))))))
4532 (around tramp-advice-PC-expand-many-files (name) activate)
4534 (if (tramp-tramp-file-p name)
4535 (setq ad-return-value (tramp-handle-expand-many-files name))
4540 ;;; File name handler functions for completion mode
4543 "If non-nil, we are in file name completion mode.")
4545 ;; Necessary because `tramp-file-name-regexp-unified' and
4546 ;; `tramp-completion-file-name-regexp-unified' aren't different.
4548 ;; `tramp-file-name-handler'). Otherwise, it takes `tramp-run-real-handler'.
4549 ;; Using `last-input-event' is a little bit risky, because completing a file
4552 ;; shouldn't have partial tramp file name syntax. Maybe another variable should
4554 ;; file name syntax in order to avoid ambiguities, like in XEmacs ...
4555 ;; In case of non unified file names it can be always true (and wouldn't be
4557 (defun tramp-completion-mode (file)
4558 "Checks whether method / user name / host name completion is active."
4561 ((string-match "^/.*:.*:$" file) nil)
4565 file)
4566 (member (match-string 1 file) (mapcar 'car tramp-methods)))
4592 ;; Method, host name and user name completion.
4593 ;; `tramp-completion-dissect-file-name' returns a list of
4594 ;; tramp-file-name structures. For all of them we return possible completions.
4596 (defun tramp-completion-handle-file-name-all-completions (filename directory)
4597 "Like `file-name-all-completions' for partial tramp files."
4604 ((fullname (concat directory filename))
4606 (v (tramp-completion-dissect-file-name fullname))
4611 (multi-method (tramp-file-name-multi-method car))
4612 (method (tramp-file-name-method car))
4613 (user (tramp-file-name-user car))
4614 (host (tramp-file-name-host car))
4615 (localname (tramp-file-name-localname car))
4651 'result1 (substring car (length directory))))
4661 'file-name-all-completions (list filename directory))
4664 'file-name-all-completions (list filename directory)))
4669 ;; Method, host name and user name completion for a file.
4671 (defun tramp-completion-handle-file-name-completion
4672 (filename directory &optional predicate)
4673 "Like `file-name-completion' for tramp files."
4676 (mapcar 'list (file-name-all-completions filename directory))
4678 (lambda (x) (funcall predicate (expand-file-name (car x) directory))))))
4680 ;; I misuse a little bit the tramp-file-name structure in order to handle
4682 ;; Return value is a list of tramp-file-name structures according to possible
4703 (defun tramp-completion-dissect-file-name (name)
4704 "Returns a list of `tramp-file-name' structures.
4705 They are collected by `tramp-completion-dissect-file-name1'."
4710 (tramp-completion-file-name-structure1
4714 (tramp-completion-file-name-structure2
4718 (tramp-completion-file-name-structure3
4722 (tramp-completion-file-name-structure4
4728 (tramp-completion-file-name-structure5
4734 (tramp-completion-file-name-structure6
4740 (tramp-completion-file-name-structure7
4749 (tramp-completion-dissect-file-name1 regexp name)))
4751 tramp-completion-file-name-structure1
4752 tramp-completion-file-name-structure2
4753 tramp-completion-file-name-structure3
4754 tramp-completion-file-name-structure4
4755 tramp-completion-file-name-structure5
4756 tramp-completion-file-name-structure6
4757 tramp-completion-file-name-structure7
4758 tramp-file-name-structure))
4762 (defun tramp-completion-dissect-file-name1 (structure name)
4763 "Returns a `tramp-file-name' structure matching STRUCTURE.
4769 (when (string-match (nth 0 structure) name)
4771 (match-string (nth 1 structure) name)))
4774 (make-tramp-file-name
4781 (match-string (nth 2 structure) name)))
4783 (match-string (nth 3 structure) name)))
4785 (match-string (nth 4 structure) name))))
4786 (make-tramp-file-name
4801 (tramp-make-tramp-file-name nil method nil nil nil)))
4806 "Returns the most expanded string for user and host name completion.
4834 (tramp-make-tramp-file-name nil method user host nil)))
4841 (when (file-readable-p filename)
4843 (insert-file-contents filename)
4878 (when (file-readable-p filename)
4880 (insert-file-contents filename)
4907 (when (file-readable-p filename)
4909 (insert-file-contents filename)
4936 (files (when (file-directory-p dirname) (directory-files dirname)))
4951 (files (when (file-directory-p dirname) (directory-files dirname)))
4965 (when (file-readable-p filename)
4967 (insert-file-contents filename)
4991 ;; as default. Unfortunately, we have no information whether any user name
4993 ;; assuming it is set in `tramp-completion-handle-file-name-all-completions'.
5001 (when (file-readable-p filename)
5003 (insert-file-contents filename)
5028 (when (file-readable-p filename)
5030 (insert-file-contents filename)
5055 (defun tramp-maybe-send-perl-script (multi-method method user host script name)
5063 (unless (memq name perl-scripts)
5065 (tramp-message 5 (concat "Sending the Perl script `" name "'..."))
5067 (concat name
5074 (tramp-set-connection-property "perl-scripts" (cons name perl-scripts)
5076 (tramp-message 5 (concat "Sending the Perl script `" name "'...done.")))))))
5079 (when (and (buffer-file-name)
5080 (tramp-tramp-file-p (buffer-file-name))
5082 (eq (tramp-find-foreign-file-name-handler (buffer-file-name))
5083 'tramp-sh-file-name-handler)
5086 (add-hook 'find-file-hooks 'tramp-set-auto-save t)
5089 (remove-hook 'find-file-hooks 'tramp-set-auto-save)))
5094 (let ((v (tramp-dissect-file-name filename)))
5097 (tramp-file-name-multi-method v) (tramp-file-name-method v)
5098 (tramp-file-name-user v) (tramp-file-name-host v)
5100 (tramp-shell-quote-argument (tramp-file-name-localname v)))))))
5107 (let* ((v1 (tramp-dissect-file-name file1))
5108 (v2 (tramp-dissect-file-name file2))
5109 (mmethod1 (tramp-file-name-multi-method v1))
5110 (mmethod2 (tramp-file-name-multi-method v2))
5111 (method1 (tramp-file-name-method v1))
5112 (method2 (tramp-file-name-method v2))
5113 (user1 (tramp-file-name-user v1))
5114 (user2 (tramp-file-name-user v2))
5115 (host1 (tramp-file-name-host v1))
5116 (host2 (tramp-file-name-host v2))
5117 (localname1 (tramp-file-name-localname v1))
5118 (localname2 (tramp-file-name-localname v2)))
5135 (defun tramp-touch (file time)
5136 "Set the last-modified timestamp of the given file.
5148 (if (tramp-tramp-file-p file)
5149 (with-parsed-tramp-file-name file nil
5161 ;; It's a local file
5164 "touch" nil (current-buffer) nil "-t" touch-time file))
5168 (defun tramp-buffer-name (multi-method method user host)
5169 "A name for the connection buffer for USER at HOST using METHOD."
5171 (tramp-buffer-name-multi-method "tramp" multi-method method user host)
5177 (defun tramp-buffer-name-multi-method (prefix multi-method method user host)
5178 "A name for the multi method connection buffer.
5202 (get-buffer-create (tramp-buffer-name multi-method method user host))
5206 (defun tramp-debug-buffer-name (multi-method method user host)
5207 "A name for the debug buffer for USER at HOST using METHOD."
5209 (tramp-buffer-name-multi-method "debug tramp"
5220 (tramp-debug-buffer-name multi-method method user host))
5229 to search. If IGNORE-TILDE is non-nil, directory names starting
5232 Returns the absolute file name of PROGNAME, if found, and nil otherwise.
5266 I.e., for each directory in DIRLIST, it is tested whether it exists and if
5272 (file-exists-p
5273 (tramp-make-tramp-file-name multi-method method user host x))
5274 (file-directory-p
5275 (tramp-make-tramp-file-name multi-method method user host x)))
5287 (defun tramp-find-file-exists-command (multi-method method user host)
5288 "Find a command on the remote host for checking if a file exists.
5290 file exists and nonzero exit status otherwise."
5291 (make-local-variable 'tramp-file-exists-command)
5292 (tramp-message 9 "Finding command to check if file exists")
5294 (tramp-make-tramp-file-name
5296 "/")) ;assume this file always exists
5298 (tramp-make-tramp-file-name
5300 "/ this file does not exist "))) ;assume this never exists
5303 ;; true, as the root directory always exists. And then we run
5304 ;; `$cmd /this\ file\ does\ not\ exist', hoping that the file indeed
5319 (and (setq tramp-file-exists-command "test -e %s")
5320 (file-exists-p existing)
5321 (not (file-exists-p nonexisting)))
5322 (and (setq tramp-file-exists-command "/bin/test -e %s")
5323 (file-exists-p existing)
5324 (not (file-exists-p nonexisting)))
5325 (and (setq tramp-file-exists-command "/usr/bin/test -e %s")
5326 (file-exists-p existing)
5327 (not (file-exists-p nonexisting)))
5328 (and (setq tramp-file-exists-command "ls -d %s")
5329 (file-exists-p existing)
5330 (not (file-exists-p nonexisting))))
5331 (error "Couldn't find command to check if file exists"))))
5386 METHOD, USER and HOST specify the connection, CMD (the absolute file name of)
5390 (when (file-executable-p
5391 (tramp-make-tramp-file-name multi-method method user host cmd))
5409 (tramp-let-maybe directory-sep-char ?/ ;for XEmacs
5413 (let ((x (concat (file-name-as-directory (car dl)) cmd)))
5437 "Send the login name."
5438 (tramp-message 9 "Sending login name `%s'"
5439 (or user (user-login-name)))
5441 (process-send-string nil (concat (or user (user-login-name))
5448 (tramp-make-tramp-file-name
5534 "Send the login name."
5535 (tramp-message 9 "Sending login name `%s'" user)
5543 (tramp-make-tramp-file-name
5671 login prompt, then sends the user name USER, then waits for a remote
5675 If USER is nil, uses value returned by `(user-login-name)' instead.
5697 (or user (user-login-name)) host method)
5701 (let* ((default-directory (tramp-temporary-file-directory))
5709 (tramp-buffer-name multi-method method user host)
5747 arguments, and xx will be used as the host name to connect to.
5760 (bufnam (tramp-buffer-name multi-method method user host))
5769 x `((?t . ,(format "/tmp/%s" tramp-temp-name-prefix)))))
5782 (let* ((default-directory (tramp-temporary-file-directory))
5808 name must be equal to the local host name or to `localhost'.
5810 If USER is nil, uses value returned by user-login-name instead.
5822 (system-name))
5834 (let* ((default-directory (tramp-temporary-file-directory))
5842 (tramp-buffer-name multi-method method user host)
5867 ;; handle not giving a user name in the "file name".
5872 ;; name is different than the "original" name (or different from
5876 This uses a slightly changed file name syntax. The idea is to say
5877 [multi/telnet:u1@h1/rsh:u2@h2]/path/to/file
5899 (let* ((default-directory (tramp-temporary-file-directory))
5906 (p (start-process (tramp-buffer-name multi-method method user host)
5916 (pop-to-buffer (buffer-name))
5937 ;; of no user name provided. Hack to make it work as it did before:
5938 ;; changed `user' to `(or user (user-login-name))' in the places where
5944 the host name, and `%n' is replaced with an end of line character, as
5948 If USER is nil, uses the return value of (user-login-name) instead."
5960 ;; of no user name provided. Hack to make it work as it did before:
5961 ;; changed `user' to `(or user (user-login-name))' in the places where
5967 with the user name, `%h' will be replaced with the host name, and `%n'
5971 If USER is nil, uses the return value of (user-login-name) instead."
5973 (?u . ,(or user (user-login-name)))
5976 (?u . ,(or user (user-login-name)))
5986 ;; of no user name provided. Hack to make it work as it did before:
5987 ;; changed `user' to `(or user (user-login-name))' in the places where
5992 HOST. The HOST name is ignored, this just changes the user id on the
5995 If USER is nil, uses the return value of (user-login-name) instead.
5998 user name, and `%n' is replaced with the value of
6001 (let ((cmd (format-spec command `((?u . ,(or user (user-login-name)))
6003 (cmd1 (format-spec command `((?u . ,(or user (user-login-name)))
6081 (pop-to-buffer (buffer-name))
6100 ;; given in the "File name" very poorly. Then, the local
6130 ;; the current working directory but /bin/sh will display a dollar
6136 ;; called as sh) on startup; this way, we avoid the startup file
6150 (buffer-name))
6164 ;; This is known for FreeBSD (see comment in `send_process', file process.c).
6250 ;; checks if a file exists. This is done because Tramp wants to use
6272 (tramp-find-file-exists-command multi-method method user host)
6284 (tramp-message 5 "Using remote command `%s' for getting directory listings"
6415 (buffer-name)))
6463 plain file on standard input and writing the encoded file to standard
6465 accepting an encoded file on standard input and writing the decoded
6466 file to standard output.
6559 If CMD contains \"%s\", provide input file INPUT there in command.
6646 "Couldn't `%s', see buffer `%s'" command (buffer-name)))
6753 ;; `file-attributes' implementation, for instance.) Therefore, we
6879 (defun tramp-convert-file-attributes (multi-method method user host attr)
6880 "Convert file-attributes ATTR generated by perl script or ls.
6881 Convert file mode bits to string and set virtual device number.
6883 ;; Convert file mode bits to string.
6885 (setcar (nthcdr 8 attr) (tramp-file-mode-from-int (nth 8 attr))))
6886 ;; Set file's gid change bit. Possible only when id-format is 'integer.
6899 (let ((string (tramp-make-tramp-file-name multi-method method user host "")))
6905 (defun tramp-file-mode-from-int (mode)
6906 "Turn an integer representing a file mode into an ls(1)-like string."
6907 (let ((type (cdr (assoc (logand (lsh mode -12) 15) tramp-file-mode-type-map)))
6914 (setq user (tramp-file-mode-permissions user suid "s"))
6915 (setq group (tramp-file-mode-permissions group sgid "s"))
6916 (setq other (tramp-file-mode-permissions other sticky "t"))
6920 (defun tramp-file-mode-permissions (perm suid suid-text)
6922 This is used internally by `tramp-file-mode-from-int'."
6974 ;; -- TRAMP file names --
6980 (defstruct tramp-file-name multi-method method user host localname)
6982 (defun tramp-tramp-file-p (name)
6983 "Return t iff NAME is a tramp file."
6985 (string-match tramp-file-name-regexp name)))
6987 ;; HHH: Changed. Used to assign the return value of (user-login-name)
6988 ;; to the `user' part of the structure if a user name was not
6990 (defun tramp-dissect-file-name (name)
6991 "Return an `tramp-file-name' structure.
6993 localname (file name on remote host)."
6995 (let* ((match (string-match (nth 0 tramp-file-name-structure) name))
6998 (if match (match-string (nth 1 tramp-file-name-structure) name)
7001 (format (nth 0 tramp-multi-file-name-structure)
7002 (nth 0 tramp-multi-file-name-hop-structure)) name)
7003 (match-string (nth 1 tramp-multi-file-name-structure) name))))
7005 ;; If it's a multi method, the file name structure contains
7007 (tramp-dissect-multi-file-name name)
7009 (unless match (error "Not a tramp file name: %s" name))
7010 (let ((user (match-string (nth 2 tramp-file-name-structure) name))
7011 (host (match-string (nth 3 tramp-file-name-structure) name))
7012 (localname (match-string (nth 4 tramp-file-name-structure) name)))
7013 (make-tramp-file-name
7041 ;; a user name is not provided in the "file name" very well.
7042 (defun tramp-dissect-multi-file-name (name)
7044 (let ((regexp (nth 0 tramp-multi-file-name-structure))
7045 (method-index (nth 1 tramp-multi-file-name-structure))
7046 (hops-index (nth 2 tramp-multi-file-name-structure))
7047 (localname-index (nth 3 tramp-multi-file-name-structure))
7048 (hop-regexp (nth 0 tramp-multi-file-name-hop-structure))
7049 (hop-method-index (nth 1 tramp-multi-file-name-hop-structure))
7050 (hop-user-index (nth 2 tramp-multi-file-name-hop-structure))
7051 (hop-host-index (nth 3 tramp-multi-file-name-hop-structure))
7053 (unless (string-match (format regexp hop-regexp) name)
7054 (error "Not a multi tramp file name: %s" name))
7055 (setq method (match-string method-index name))
7056 (setq hops (match-string hops-index name))
7059 (setq localname (match-string localname-index name))
7069 (make-tramp-file-name
7076 (defun tramp-make-tramp-file-name (multi-method method user host localname)
7077 "Constructs a tramp file name from METHOD, USER, HOST and LOCALNAME."
7079 (tramp-make-tramp-multi-file-name multi-method method user host localname)
7090 (defun tramp-make-tramp-multi-file-name (multi-method method user host localname)
7091 "Constructs a tramp file name for a multi-hop method."
7092 (unless tramp-make-multi-tramp-file-format
7093 (error "`tramp-make-multi-tramp-file-format' is nil"))
7094 (let* ((prefix-format (nth 0 tramp-make-multi-tramp-file-format))
7095 (hop-format (nth 1 tramp-make-multi-tramp-file-format))
7096 (localname-format (nth 2 tramp-make-multi-tramp-file-format))
7109 (defun tramp-make-copy-program-file-name (user host localname)
7110 "Create a file name suitable to be passed to `rcp' and workalikes."
7138 (defun tramp-get-file-exists-command (multi-method method user host)
7143 tramp-file-exists-command)
7225 ;; Auto saving to a special directory.
7227 (defun tramp-exists-file-name-handler (operation &rest args)
7228 (let ((buffer-file-name "/")
7229 (fnha file-name-handler-alist)
7230 (check-file-name-operation operation)
7231 (file-name-handler-alist
7236 (if (equal check-file-name-operation operation)
7238 (let ((file-name-handler-alist fnha))
7242 (unless (tramp-exists-file-name-handler 'make-auto-save-file-name)
7243 (defadvice make-auto-save-file-name
7244 (around tramp-advice-make-auto-save-file-name () activate)
7245 "Invoke `tramp-handle-make-auto-save-file-name' for tramp files."
7246 (if (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name)))
7247 (setq ad-return-value (tramp-handle-make-auto-save-file-name))
7250 '(lambda () (ad-unadvise 'make-auto-save-file-name))))
7255 (defun tramp-set-auto-save-file-modes ()
7257 (let ((bfn (buffer-file-name)))
7259 (tramp-tramp-file-p bfn)
7260 (stringp buffer-auto-save-file-name)
7261 (not (equal bfn buffer-auto-save-file-name)))
7262 (unless (file-exists-p buffer-auto-save-file-name)
7263 (write-region "" nil buffer-auto-save-file-name))
7265 ;; auto-saved file belonging to another original file. This could
7267 (set-file-modes buffer-auto-save-file-name
7268 (or (file-modes bfn) (tramp-octal-to-decimal "0600"))))))
7274 (add-hook 'auto-save-hook 'tramp-set-auto-save-file-modes)
7277 (remove-hook 'auto-save-hook 'tramp-set-auto-save-file-modes))))
7302 (defun tramp-temporary-file-directory ()
7303 "Return name of directory for temporary files (compat function).
7304 For Emacs, this is the variable `temporary-file-directory', for XEmacs
7305 this is the function `temp-directory'."
7306 (cond ((boundp 'temporary-file-directory)
7307 (symbol-value 'temporary-file-directory))
7308 ((fboundp 'temp-directory)
7309 (funcall (symbol-function 'temp-directory))) ;pacify byte-compiler
7310 ((let ((d (getenv "TEMP"))) (and d (file-directory-p d)))
7311 (file-name-as-directory (getenv "TEMP")))
7312 ((let ((d (getenv "TMP"))) (and d (file-directory-p d)))
7313 (file-name-as-directory (getenv "TMP")))
7314 ((let ((d (getenv "TMPDIR"))) (and d (file-directory-p d)))
7315 (file-name-as-directory (getenv "TMPDIR")))
7316 ((file-exists-p "c:/temp") (file-name-as-directory "c:/temp"))
7317 (t (message (concat "Neither `temporary-file-directory' nor "
7318 "`temp-directory' is defined -- using /tmp."))
7319 (file-name-as-directory "/tmp"))))
7325 (let* ((key (concat (or user (user-login-name)) "@" host))
7334 (let ((filename (or buffer-file-name list-buffers-directory "")))
7336 (or (and user host) (tramp-tramp-file-p filename)))
7337 (let* ((v (when (tramp-tramp-file-p filename)
7338 (tramp-dissect-file-name filename)))
7339 (luser (or user (tramp-file-name-user v) (user-login-name)))
7340 (lhost (or host (tramp-file-name-host v) (system-name)))
7395 Note: this function has been written for `tramp-handle-file-truename'.
7455 ;; ;; EFS hooks itself into the file name handling stuff in more places
7456 ;; ;; than just `file-name-handler-alist'. The following tells EFS to stay
7457 ;; ;; away from tramp.el file names.
7474 ;; (if (tramp-tramp-file-p (ad-get-arg 0))
7480 ;; `find-file-wildcards' is non-nil, and then barfs because no
7482 ;; something really awful: we have `file-expand-wildcards' return the
7488 (defadvice file-expand-wildcards (around tramp-fix activate)
7489 (let ((name (ad-get-arg 0)))
7490 (if (tramp-tramp-file-p name)
7491 ;; If it's a Tramp file, dissect it and look if wildcards
7493 (let ((v (tramp-dissect-file-name name)))
7494 (if (string-match "[[*?]" (tramp-file-name-localname v))
7496 (setq ad-return-value (or res (list name))))
7497 (setq ad-return-value (list name))))
7498 ;; If it is not a Tramp file, just run the original function.
7500 (setq ad-return-value (or res (list name)))))))
7502 '(lambda () (ad-unadvise 'file-expand-wildcards))))
7525 (format "tramp (%s)" tramp-version) ; package name and version
7530 tramp-file-exists-command
7537 tramp-auto-save-directory ; vars to dump
7549 tramp-temp-name-prefix
7550 tramp-file-name-structure
7551 tramp-file-name-regexp
7552 tramp-multi-file-name-structure
7553 tramp-multi-file-name-hop-structure
7566 ,(when (boundp 'tramp-backup-directory-alist)
7567 'tramp-backup-directory-alist)
7568 ,(when (boundp 'tramp-bkup-backup-directory-info)
7569 'tramp-bkup-backup-directory-info)
7583 ,(when (boundp 'backup-directory-alist)
7584 'backup-directory-alist)
7585 ,(when (boundp 'bkup-backup-directory-info)
7586 'bkup-backup-directory-info)
7587 file-name-handler-alist))
7601 the ~/.emacs file and to repeat the bug. Then, include the contents
7670 (when (string-match tramp-buf-regexp (buffer-name b)) b))
7715 'disposition "attachment" 'buffer (buffer-name buffer)
7716 'description (buffer-name buffer)))
7729 ;; - Reset `file-name-handler-alist'
7738 (tramp-unload-file-name-handlers)
7768 ;; Another approach is to read a netrc file like ~/.authinfo
7777 ;; and which writes the right bytes to the file. We can use printf(1)
7791 ;; * Completion gets confused when you leave out the method name.
7792 ;; * In Emacs 21, `insert-directory' shows total number of bytes used
7793 ;; by the files in that directory. Add this here.
7808 ;; * `vc-directory' does not work. It never displays any files, even
7812 ;; * How to deal with MULE in `insert-file-contents' and `write-region'?
7816 ;; * abbreviate-file-name
7829 ;; * Invoke rsync once for copying a whole directory hierarchy.
7834 ;; * Make it work for different encodings, and for different file name
7836 ;; * Change applicable functions to pass a struct tramp-file-name rather
7845 ;; * When editing a remote CVS controlled file as a different user, VC
7846 ;; gets confused about the file locking status. Try to find out why
7848 ;; * Change `copy-file' to grok the case where the filename handler
7849 ;; for the source and the target file are different. Right now,
7850 ;; it looks at the source file and then calls that handler, if
7852 ;; about Tramp, it does not do the right thing if the target file
7853 ;; name is a Tramp name.
7869 ;; Functions for file-name-handler-alist:
7870 ;; diff-latest-backup-file -- in diff.el
7871 ;; dired-uncache -- this will be needed when we do insert-directory caching
7872 ;; file-name-as-directory -- use primitive?
7873 ;; file-name-sans-versions -- use primitive?
7874 ;; get-file-buffer -- use primitive