Commit a69c01a0 authored by Michael Albinus's avatar Michael Albinus
Browse files

Sync with Tramp 2.0.52.

parent 6e36b4ff
2006-01-22 Michael Albinus <michael.albinus@gmx.de>
Sync with Tramp 2.0.52.
* net/tramp.el, net/tramp-ftp.el, net/tramp-util.el,
net/tramp-vc.el: Add code for unloading Tramp. See comment before
`tramp-unload-tramp' for checklist.
* net/tramp.el: Require `timer-funcs' instead of `timer' if in
XEmacs. Contributed by Steve Youngs <steve@sxemacs.org>.
(tramp-unload-file-name-handler-alist)
(tramp-unload-tramp): New defuns.
(tramp-advice-PC-expand-many-files): New defadvice.
(tramp-save-PC-expand-many-files, tramp-setup-complete) Defuns
removed.
(tramp-handle-expand-file-name): Remove double slash.
(tramp-handle-file-attributes-with-ls): Return t as 9th attribute.
It doesn't matter, because it will be converted later on.
(tramp-handle-file-ownership-preserved-p): Rewritten. The old
implementation was just heuristic.
(tramp-post-connection): Set uid and gid properties.
(tramp-convert-file-attributes): Set file's gid change bit.
(tramp-get-remote-uid, tramp-get-remote-gid): New defuns.
(tramp-handle-expand-file-name): Use "~root" for tilde expansion
in case of su(do)? methods. The home directory of the local user
will be taken else.
(tramp-open-connection-telnet)
(tramp-open-connection-rsh, tramp-open-connection-su)
(tramp-open-connection-multi): Set PS1 to "$ ". Otherwise, a
local shell prompt could hurt. Reported by Romain Francoise
<romain@orebokech.com>.
(tramp-let-maybe): Add `edebug-form-spec' property.
(tramp-handle-expand-file-name): Bind `default-directory' locally
to "/" in order to avoid problems with UNC shares or Cygwin
mounts.
(tramp-md5-function): Fix typo in error message.
* net/tramp-ftp.el (tramp-ftp-enable-ange-ftp): New defun.
* net/tramp-util.el (top): Apply `ignore' instead of `identity'
for byte-compiler pacification.
2006-01-22 Andre Spiegel <spiegel@gnu.org> 2006-01-22 Andre Spiegel <spiegel@gnu.org>
   
* vc-rcs.el (vc-rcs-state-heuristic): Use file-attributes with * vc-rcs.el (vc-rcs-state-heuristic): Use file-attributes with
......
;;; tramp-ftp.el --- Tramp convenience functions for Ange-FTP -*- coding: iso-8859-1; -*- ;;; tramp-ftp.el --- Tramp convenience functions for Ange-FTP -*- coding: iso-8859-1; -*-
;; Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. ;; Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
;; Author: Michael Albinus <michael.albinus@gmx.de> ;; Author: Michael Albinus <michael.albinus@gmx.de>
;; Keywords: comm, processes ;; Keywords: comm, processes
...@@ -63,8 +63,40 @@ present for backward compatibility." ...@@ -63,8 +63,40 @@ present for backward compatibility."
(a2 (rassq 'ange-ftp-completion-hook-function file-name-handler-alist))) (a2 (rassq 'ange-ftp-completion-hook-function file-name-handler-alist)))
(setq file-name-handler-alist (setq file-name-handler-alist
(delete a1 (delete a2 file-name-handler-alist))))) (delete a1 (delete a2 file-name-handler-alist)))))
(tramp-disable-ange-ftp)
(eval-after-load "ange-ftp" '(tramp-disable-ange-ftp)) (eval-after-load "ange-ftp"
'(when (functionp 'tramp-disable-ange-ftp)
(tramp-disable-ange-ftp)))
;;;###autoload
(defun tramp-ftp-enable-ange-ftp ()
;; The following code is commented out in Ange-FTP.
;;; This regexp takes care of real ange-ftp file names (with a slash
;;; and colon).
;;; Don't allow the host name to end in a period--some systems use /.:
(or (assoc "^/[^/:]*[^/:.]:" file-name-handler-alist)
(setq file-name-handler-alist
(cons '("^/[^/:]*[^/:.]:" . ange-ftp-hook-function)
file-name-handler-alist)))
;;; This regexp recognizes absolute filenames with only one component,
;;; for the sake of hostname completion.
(or (assoc "^/[^/:]*\\'" file-name-handler-alist)
(setq file-name-handler-alist
(cons '("^/[^/:]*\\'" . ange-ftp-completion-hook-function)
file-name-handler-alist)))
;;; This regexp recognizes absolute filenames with only one component
;;; on Windows, for the sake of hostname completion.
(and (memq system-type '(ms-dos windows-nt))
(or (assoc "^[a-zA-Z]:/[^/:]*\\'" file-name-handler-alist)
(setq file-name-handler-alist
(cons '("^[a-zA-Z]:/[^/:]*\\'" .
ange-ftp-completion-hook-function)
file-name-handler-alist)))))
(add-hook 'tramp-ftp-unload-hook 'tramp-ftp-enable-ange-ftp)
;; Define FTP method ... ;; Define FTP method ...
(defcustom tramp-ftp-method "ftp" (defcustom tramp-ftp-method "ftp"
......
;;; -*- coding: iso-2022-7bit; -*- ;;; -*- coding: iso-2022-7bit; -*-
;;; tramp-util.el --- Misc utility functions to use with Tramp ;;; tramp-util.el --- Misc utility functions to use with Tramp
;; Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. ;; Copyright (C) 2001, 2002, 2003, 2004, 2005,
;; 2006 Free Software Foundation, Inc.
;; Author: kai.grossjohann@gmx.net ;; Author: kai.grossjohann@gmx.net
;; Keywords: comm, extensions, processes ;; Keywords: comm, extensions, processes
...@@ -31,6 +32,10 @@ ...@@ -31,6 +32,10 @@
(eval-when-compile (require 'cl)) (eval-when-compile (require 'cl))
(require 'compile) (require 'compile)
(require 'tramp) (require 'tramp)
(add-hook 'tramp-util-unload-hook
'(lambda ()
(when (featurep 'tramp)
(unload-feature 'tramp 'force))))
;; Define a Tramp minor mode. It's intention is to redefine some keys for Tramp ;; Define a Tramp minor mode. It's intention is to redefine some keys for Tramp
;; specific functions, like compilation. ;; specific functions, like compilation.
...@@ -42,7 +47,7 @@ ...@@ -42,7 +47,7 @@
(defalias 'define-minor-mode 'identity) (defalias 'define-minor-mode 'identity)
(defvar tramp-minor-mode)) (defvar tramp-minor-mode))
(unless (featurep 'xemacs) (unless (featurep 'xemacs)
(defalias 'add-menu-button 'identity))) (defalias 'add-menu-button 'ignore)))
(defvar tramp-minor-mode-map (make-sparse-keymap) (defvar tramp-minor-mode-map (make-sparse-keymap)
"Keymap for Tramp minor mode.") "Keymap for Tramp minor mode.")
...@@ -57,7 +62,14 @@ ...@@ -57,7 +62,14 @@
(and tramp-minor-mode (tramp-tramp-file-p default-directory)))) (and tramp-minor-mode (tramp-tramp-file-p default-directory))))
(add-hook 'find-file-hooks 'tramp-minor-mode t) (add-hook 'find-file-hooks 'tramp-minor-mode t)
(add-hook 'tramp-util-unload-hook
'(lambda ()
(remove-hook 'find-file-hooks 'tramp-minor-mode)))
(add-hook 'dired-mode-hook 'tramp-minor-mode t) (add-hook 'dired-mode-hook 'tramp-minor-mode t)
(add-hook 'tramp-util-unload-hook
'(lambda ()
(remove-hook 'dired-mode-hook 'tramp-minor-mode)))
(defun tramp-remap-command (old-command new-command) (defun tramp-remap-command (old-command new-command)
"Replaces bindings of OLD-COMMAND by NEW-COMMAND. "Replaces bindings of OLD-COMMAND by NEW-COMMAND.
......
;;; tramp-vc.el --- Version control integration for TRAMP.el ;;; tramp-vc.el --- Version control integration for TRAMP.el
;; Copyright (C) 2000, 2001, 2002, 2003, 2004, ;; Copyright (C) 2000, 2001, 2002, 2003, 2004,
;; 2005 Free Software Foundation, Inc. ;; 2005, 2006 Free Software Foundation, Inc.
;; Author: Daniel Pittman <daniel@danann.net> ;; Author: Daniel Pittman <daniel@danann.net>
;; Keywords: comm, processes ;; Keywords: comm, processes
...@@ -220,34 +220,37 @@ Since TRAMP doesn't do async commands yet, this function doesn't, either." ...@@ -220,34 +220,37 @@ Since TRAMP doesn't do async commands yet, this function doesn't, either."
;; Daniel Pittman <daniel@danann.net> ;; Daniel Pittman <daniel@danann.net>
;;-(if (fboundp 'vc-call-backend) ;;-(if (fboundp 'vc-call-backend)
;;- () ;; This is the new VC for which we don't have an appropriate advice yet ;;- () ;; This is the new VC for which we don't have an appropriate advice yet
;;-)
(unless (fboundp 'process-file) (unless (fboundp 'process-file)
(if (fboundp 'vc-call-backend) (if (fboundp 'vc-call-backend)
(defadvice vc-do-command
(around tramp-advice-vc-do-command
(buffer okstatus command file &rest flags)
activate)
"Invoke tramp-vc-do-command for tramp files."
(let ((file (symbol-value 'file))) ;pacify byte-compiler
(if (or (and (stringp file) (tramp-tramp-file-p file))
(and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name))))
(setq ad-return-value
(apply 'tramp-vc-do-command-new buffer okstatus command
file ;(or file (buffer-file-name))
flags))
ad-do-it)))
(defadvice vc-do-command (defadvice vc-do-command
(around tramp-advice-vc-do-command (around tramp-advice-vc-do-command
(buffer okstatus command file &rest flags) (buffer okstatus command file last &rest flags)
activate) activate)
"Invoke tramp-vc-do-command for tramp files." "Invoke tramp-vc-do-command for tramp files."
(let ((file (symbol-value 'file))) ;pacify byte-compiler (let ((file (symbol-value 'file))) ;pacify byte-compiler
(if (or (and (stringp file) (tramp-tramp-file-p file)) (if (or (and (stringp file) (tramp-tramp-file-p file))
(and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name)))) (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name))))
(setq ad-return-value (setq ad-return-value
(apply 'tramp-vc-do-command-new buffer okstatus command (apply 'tramp-vc-do-command buffer okstatus command
file ;(or file (buffer-file-name)) (or file (buffer-file-name)) last flags))
flags)) ad-do-it))))
ad-do-it)))
(defadvice vc-do-command (add-hook 'tramp-unload-hook
(around tramp-advice-vc-do-command '(lambda () (ad-unadvise 'vc-do-command))))
(buffer okstatus command file last &rest flags)
activate)
"Invoke tramp-vc-do-command for tramp files."
(let ((file (symbol-value 'file))) ;pacify byte-compiler
(if (or (and (stringp file) (tramp-tramp-file-p file))
(and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name))))
(setq ad-return-value
(apply 'tramp-vc-do-command buffer okstatus command
(or file (buffer-file-name)) last flags))
ad-do-it)))))
;;-)
;; XEmacs uses this to do some of its work. Like vc-do-command, we ;; XEmacs uses this to do some of its work. Like vc-do-command, we
...@@ -324,6 +327,9 @@ Since TRAMP doesn't do async commands yet, this function doesn't, either." ...@@ -324,6 +327,9 @@ Since TRAMP doesn't do async commands yet, this function doesn't, either."
(or file (buffer-file-name)) args)) (or file (buffer-file-name)) args))
ad-do-it))) ad-do-it)))
(add-hook 'tramp-unload-hook
'(lambda () (ad-unadvise 'vc-simple-command)))
;; `vc-workfile-unchanged-p' ;; `vc-workfile-unchanged-p'
;; This function does not deal well with remote files, so we do the ;; This function does not deal well with remote files, so we do the
...@@ -364,6 +370,9 @@ Since TRAMP doesn't do async commands yet, this function doesn't, either." ...@@ -364,6 +370,9 @@ Since TRAMP doesn't do async commands yet, this function doesn't, either."
(tramp-vc-workfile-unchanged-p filename want-differences-if-changed)) (tramp-vc-workfile-unchanged-p filename want-differences-if-changed))
ad-do-it)) ad-do-it))
(add-hook 'tramp-unload-hook
'(lambda () (ad-unadvise 'vc-workfile-unchanged-p)))
;; Redefine a function from vc.el -- allow tramp files. ;; Redefine a function from vc.el -- allow tramp files.
;; `save-match-data' seems not to be required -- it isn't in ;; `save-match-data' seems not to be required -- it isn't in
...@@ -445,6 +454,9 @@ filename we are thinking about..." ...@@ -445,6 +454,9 @@ filename we are thinking about..."
(tramp-handle-vc-user-login-name uid)))) ; get the owner name (tramp-handle-vc-user-login-name uid)))) ; get the owner name
ad-do-it))) ; else call the original ad-do-it))) ; else call the original
(add-hook 'tramp-unload-hook
'(lambda () (ad-unadvise 'vc-user-login-name)))
;; Determine the name of the user owning a file. ;; Determine the name of the user owning a file.
(defun tramp-file-owner (filename) (defun tramp-file-owner (filename)
...@@ -486,6 +498,9 @@ filename we are thinking about..." ...@@ -486,6 +498,9 @@ filename we are thinking about..."
(tramp-file-owner filename)))) ; get the owner name (tramp-file-owner filename)))) ; get the owner name
ad-do-it))) ; else call the original ad-do-it))) ; else call the original
(add-hook 'tramp-unload-hook
'(lambda () (ad-unadvise 'vc-file-owner)))
;; We need to make the version control software backend version ;; We need to make the version control software backend version
;; information local to the current buffer. This is because each TRAMP ;; information local to the current buffer. This is because each TRAMP
...@@ -506,7 +521,11 @@ This makes remote VC work correctly at the cost of some processing time." ...@@ -506,7 +521,11 @@ This makes remote VC work correctly at the cost of some processing time."
(tramp-tramp-file-p (buffer-file-name))) (tramp-tramp-file-p (buffer-file-name)))
(make-local-variable 'vc-rcs-release) (make-local-variable 'vc-rcs-release)
(setq vc-rcs-release nil))) (setq vc-rcs-release nil)))
(add-hook 'find-file-hooks 'tramp-vc-setup-for-remote t) (add-hook 'find-file-hooks 'tramp-vc-setup-for-remote t)
(add-hook 'tramp-unload-hook
'(lambda ()
(remove-hook 'find-file-hooks 'tramp-vc-setup-for-remote)))
;; No need to load this again if anyone asks. ;; No need to load this again if anyone asks.
(provide 'tramp-vc) (provide 'tramp-vc)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
;;; tramp.el --- Transparent Remote Access, Multiple Protocol ;;; tramp.el --- Transparent Remote Access, Multiple Protocol
;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
;; 2005 Free Software Foundation, Inc. ;; 2005, 2006 Free Software Foundation, Inc.
;; Author: Kai Gro,A_(Bjohann <kai.grossjohann@gmx.net> ;; Author: Kai Gro,A_(Bjohann <kai.grossjohann@gmx.net>
;; Michael Albinus <michael.albinus@gmx.de> ;; Michael Albinus <michael.albinus@gmx.de>
...@@ -67,8 +67,15 @@ ...@@ -67,8 +67,15 @@
;; The Tramp version number and bug report address, as prepared by configure. ;; The Tramp version number and bug report address, as prepared by configure.
(require 'trampver) (require 'trampver)
(add-hook 'tramp-unload-hook
'(lambda ()
(when (featurep 'trampver)
(unload-feature 'trampver 'force))))
(if (featurep 'xemacs)
(require 'timer-funcs)
(require 'timer))
(require 'timer)
(require 'format-spec) ;from Gnus 5.8, also in tar ball (require 'format-spec) ;from Gnus 5.8, also in tar ball
;; As long as password.el is not part of (X)Emacs, it shouldn't ;; As long as password.el is not part of (X)Emacs, it shouldn't
;; be mandatory ;; be mandatory
...@@ -87,6 +94,10 @@ ...@@ -87,6 +94,10 @@
(autoload 'tramp-uuencode-region "tramp-uu" (autoload 'tramp-uuencode-region "tramp-uu"
"Implementation of `uuencode' in Lisp.") "Implementation of `uuencode' in Lisp.")
(add-hook 'tramp-unload-hook
'(lambda ()
(when (featurep 'tramp-uu)
(unload-feature 'tramp-uu 'force))))
(unless (fboundp 'uudecode-decode-region) (unless (fboundp 'uudecode-decode-region)
(autoload 'uudecode-decode-region "uudecode")) (autoload 'uudecode-decode-region "uudecode"))
...@@ -110,10 +121,20 @@ Nil means to use a separate filename syntax for Tramp.") ...@@ -110,10 +121,20 @@ Nil means to use a separate filename syntax for Tramp.")
;; tramp-ftp supports Ange-FTP only. Not suited for XEmacs therefore. ;; tramp-ftp supports Ange-FTP only. Not suited for XEmacs therefore.
(unless (featurep 'xemacs) (unless (featurep 'xemacs)
(eval-after-load "tramp" (eval-after-load "tramp"
'(require 'tramp-ftp))) '(progn
(require 'tramp-ftp)
(add-hook 'tramp-unload-hook
'(lambda ()
(when (featurep 'tramp-ftp)
(unload-feature 'tramp-ftp 'force)))))))
(when (and tramp-unified-filenames (featurep 'xemacs)) (when (and tramp-unified-filenames (featurep 'xemacs))
(eval-after-load "tramp" (eval-after-load "tramp"
'(require 'tramp-efs))) '(progn
(require 'tramp-efs)
(add-hook 'tramp-unload-hook
'(lambda ()
(when (featurep 'tramp-efs)
(unload-feature 'tramp-efs 'force)))))))
;; tramp-smb uses "smbclient" from Samba. ;; tramp-smb uses "smbclient" from Samba.
;; Not available under Cygwin and Windows, because they don't offer ;; Not available under Cygwin and Windows, because they don't offer
...@@ -121,7 +142,12 @@ Nil means to use a separate filename syntax for Tramp.") ...@@ -121,7 +142,12 @@ Nil means to use a separate filename syntax for Tramp.")
;; UNC file names like "//host/share/localname". ;; UNC file names like "//host/share/localname".
(unless (memq system-type '(cygwin windows-nt)) (unless (memq system-type '(cygwin windows-nt))
(eval-after-load "tramp" (eval-after-load "tramp"
'(require 'tramp-smb))) '(progn
(require 'tramp-smb)
(add-hook 'tramp-unload-hook
'(lambda ()
(when (featurep 'tramp-smb)
(unload-feature 'tramp-smb 'force)))))))
(eval-when-compile (eval-when-compile
(require 'cl) (require 'cl)
...@@ -1445,7 +1471,7 @@ the visited file modtime.") ...@@ -1445,7 +1471,7 @@ the visited file modtime.")
((fboundp 'md5-encode) ((fboundp 'md5-encode)
(lambda (x) (base64-encode-string (lambda (x) (base64-encode-string
(funcall (symbol-function 'md5-encode) x)))) (funcall (symbol-function 'md5-encode) x))))
(t (error "Coulnd't find an `md5' function"))) (t (error "Couldn't find an `md5' function")))
"Function to call for running the MD5 algorithm.") "Function to call for running the MD5 algorithm.")
(defvar tramp-end-of-output (defvar tramp-end-of-output
...@@ -2012,6 +2038,7 @@ The intent is to protect against `obsolete variable' warnings." ...@@ -2012,6 +2038,7 @@ The intent is to protect against `obsolete variable' warnings."
(let ((,variable ,value)) (let ((,variable ,value))
,@body))) ,@body)))
(put 'tramp-let-maybe 'lisp-indent-function 2) (put 'tramp-let-maybe 'lisp-indent-function 2)
(put 'tramp-let-maybe 'edebug-form-spec t)
;;; Config Manipulation Functions: ;;; Config Manipulation Functions:
...@@ -2370,8 +2397,8 @@ target of the symlink differ." ...@@ -2370,8 +2397,8 @@ target of the symlink differ."
;; 8. File modes, as a string of ten letters or dashes as in ls -l. ;; 8. File modes, as a string of ten letters or dashes as in ls -l.
res-filemodes res-filemodes
;; 9. t iff file's gid would change if file were deleted and ;; 9. t iff file's gid would change if file were deleted and
;; recreated. ;; recreated. Will be set in `tramp-convert-file-attributes'
nil ;hm? t
;; 10. inode number. ;; 10. inode number.
res-inode res-inode
;; 11. Device number. Will be replaced by a virtual device number. ;; 11. Device number. Will be replaced by a virtual device number.
...@@ -2627,9 +2654,12 @@ of." ...@@ -2627,9 +2654,12 @@ of."
(defun tramp-handle-file-ownership-preserved-p (filename) (defun tramp-handle-file-ownership-preserved-p (filename)
"Like `file-ownership-preserved-p' for tramp files." "Like `file-ownership-preserved-p' for tramp files."
(with-parsed-tramp-file-name filename nil (with-parsed-tramp-file-name filename nil
(or (not (file-exists-p filename)) (let ((attributes (file-attributes filename)))
;; Existing files must be writable. ;; Return t if the file doesn't exist, since it's true that no
(zerop (tramp-run-test "-O" filename))))) ;; information would be lost by an (attempted) delete and create.
(or (null attributes)
(= (nth 2 attributes)
(tramp-get-remote-uid multi-method method user host))))))
;; Other file name ops. ;; Other file name ops.
...@@ -3487,6 +3517,17 @@ the result will be a local, non-Tramp, filename." ...@@ -3487,6 +3517,17 @@ the result will be a local, non-Tramp, filename."
(when (string-match "\\`\\(~[^/]*\\)\\(.*\\)\\'" localname) (when (string-match "\\`\\(~[^/]*\\)\\(.*\\)\\'" localname)
(let ((uname (match-string 1 localname)) (let ((uname (match-string 1 localname))
(fname (match-string 2 localname))) (fname (match-string 2 localname)))
;; We cannot simply apply "~/", because under sudo "~/" is
;; expanded to the local user home directory but to the
;; root home directory. On the other hand, using always
;; the default user name for tilde expansion is not
;; appropriate either, because ssh and companions might
;; use a user name from the config file.
(when (and (string-equal uname "~")
(string-match
"\\`su\\(do\\)?\\'"
(tramp-find-method multi-method method user host)))
(setq uname (concat uname (or user "root"))))
;; CCC fanatic error checking? ;; CCC fanatic error checking?
(set-buffer (tramp-get-buffer multi-method method user host)) (set-buffer (tramp-get-buffer multi-method method user host))
(erase-buffer) (erase-buffer)
...@@ -3499,17 +3540,24 @@ the result will be a local, non-Tramp, filename." ...@@ -3499,17 +3540,24 @@ the result will be a local, non-Tramp, filename."
(setq uname (buffer-substring (point) (tramp-line-end-position))) (setq uname (buffer-substring (point) (tramp-line-end-position)))
(setq localname (concat uname fname)) (setq localname (concat uname fname))
(erase-buffer))) (erase-buffer)))
;; There might be a double slash, for example when "~/"
;; expands to "/". Remove this.
(while (string-match "//" localname)
(setq localname (replace-match "/" t t localname)))
;; No tilde characters in file name, do normal ;; No tilde characters in file name, do normal
;; expand-file-name (this does "/./" and "/../"). We bind ;; expand-file-name (this does "/./" and "/../"). We bind
;; directory-sep-char here for XEmacs on Windows, which ;; directory-sep-char here for XEmacs on Windows, which would
;; would otherwise use backslash. ;; otherwise use backslash. `default-directory' is bound to
;; "/", because on Windows there would be problems with UNC
;; shares or Cygwin mounts.
(tramp-let-maybe directory-sep-char ?/ (tramp-let-maybe directory-sep-char ?/
(tramp-make-tramp-file-name (let ((default-directory "/"))
multi-method (or method (tramp-find-default-method user host)) (tramp-make-tramp-file-name
user host multi-method (or method (tramp-find-default-method user host))
(tramp-drop-volume-letter user host
(tramp-run-real-handler 'expand-file-name (tramp-drop-volume-letter
(list localname))))))))) (tramp-run-real-handler 'expand-file-name
(list localname))))))))))
;; old version follows. it uses ".." to cross file handler ;; old version follows. it uses ".." to cross file handler
;; boundaries. ;; boundaries.
...@@ -4294,6 +4342,17 @@ Falls back to normal file name handler if no tramp file name handler exists." ...@@ -4294,6 +4342,17 @@ Falls back to normal file name handler if no tramp file name handler exists."
(cons tramp-completion-file-name-regexp (cons tramp-completion-file-name-regexp
'tramp-completion-file-name-handler)) 'tramp-completion-file-name-handler))
;;;###autoload
(defun tramp-unload-file-name-handler-alist ()
(setq file-name-handler-alist
(delete (rassoc 'tramp-file-name-handler
file-name-handler-alist)
(delete (rassoc 'tramp-completion-file-name-handler
file-name-handler-alist)
file-name-handler-alist))))
(add-hook 'tramp-unload-hook 'tramp-unload-file-name-handler-alist)
(defun tramp-repair-jka-compr () (defun tramp-repair-jka-compr ()
"If jka-compr is already loaded, move it to the front of "If jka-compr is already loaded, move it to the front of
`file-name-handler-alist'. On Emacs 22 or so this will not be `file-name-handler-alist'. On Emacs 22 or so this will not be
...@@ -4353,22 +4412,16 @@ necessary anymore." ...@@ -4353,22 +4412,16 @@ necessary anymore."
(read (current-buffer)))))) (read (current-buffer))))))
(list (expand-file-name name)))))) (list (expand-file-name name))))))
;; Check for complete.el and override PC-expand-many-files if appropriate. (eval-after-load "complete"
(eval-and-compile '(progn
(defun tramp-save-PC-expand-many-files (name))); avoid compiler warning (defadvice PC-expand-many-files
(around tramp-advice-PC-expand-many-files (name) activate)
(defun tramp-setup-complete () "Invoke `tramp-handle-expand-many-files' for tramp files."
(fset 'tramp-save-PC-expand-many-files (if (tramp-tramp-file-p name)
(symbol-function 'PC-expand-many-files)) (setq ad-return-value (tramp-handle-expand-many-files name))
(defun PC-expand-many-files (name) ad-do-it))
(if (tramp-tramp-file-p name) (add-hook 'tramp-unload-hook
(funcall (symbol-function 'expand-many-files) name) '(lambda () (ad-unadvise 'PC-expand-many-files)))))
(tramp-save-PC-expand-many-files name))))
;; Why isn't eval-after-load sufficient?
(if (fboundp 'PC-expand-many-files)
(tramp-setup-complete)
(eval-after-load "complete" '(tramp-setup-complete)))
;;; File name handler functions for completion mode ;;; File name handler functions for completion mode
...@@ -4940,6 +4993,9 @@ Function may have 0-3 parameters." ...@@ -4940,6 +4993,9 @@ Function may have 0-3 parameters."
auto-save-default) auto-save-default)
(auto-save-mode 1))) (auto-save-mode 1)))
(add-hook 'find-file-hooks 'tramp-set-auto-save t) (add-hook 'find-file-hooks 'tramp-set-auto-save t)
(add-hook 'tramp-unload-hook
'(lambda ()
(remove-hook 'find-file-hooks 'tramp-set-auto-save)))
(defun tramp-run-test (switch filename) (defun tramp-run-test (switch filename)
"Run `test' on the remote system, given a SWITCH and a FILENAME. "Run `test' on the remote system, given a SWITCH and a FILENAME.
...@@ -5532,6 +5588,7 @@ Maybe the different regular expressions need to be tuned. ...@@ -5532,6 +5588,7 @@ Maybe the different regular expressions need to be tuned.
(or user (user-login-name)) host method) (or user (user-login-name)) host method)
(let ((process-environment (copy-sequence process-environment))) (let ((process-environment (copy-sequence process-environment)))
(setenv "TERM" tramp-terminal-type) (setenv "TERM" tramp-terminal-type)
(setenv "PS1" "$ ")
(let* ((default-directory (tramp-temporary-file-directory)) (let* ((default-directory (tramp-temporary-file-directory))
;; If we omit the conditional here, then we would use ;; If we omit the conditional here, then we would use
;; `undecided-dos' in some cases. With the conditional, ;; `undecided-dos' in some cases. With the conditional,
...@@ -5608,6 +5665,7 @@ arguments, and xx will be used as the host name to connect to. ...@@ -5608,6 +5665,7 @@ arguments, and xx will be used as the host name to connect to.
(setq login-args (cons "-p" (cons (match-string 2 host) login-args))) (setq login-args (cons "-p" (cons (match-string 2 host) login-args)))
(setq real-host (match-string 1 host)))