comparison lisp/net/tramp.el @ 85089:8fb95bcda144

* net/tramp.el (tramp-find-foreign-file-name-handler): Check also host. (tramp-maybe-send-script): Apply `member' but `memq'. (tramp-advice-file-expand-wildcards): Simplify implementation.
author Michael Albinus <michael.albinus@gmx.de>
date Mon, 08 Oct 2007 20:07:16 +0000
parents 4636000015c5
children 9a6e9b6e4a76 bdb3fe0ba9fa
comparison
equal deleted inserted replaced
85088:f3b4c3cf62f0 85089:8fb95bcda144
2138 l 'file-already-exists "File %s already exists" l-localname) 2138 l 'file-already-exists "File %s already exists" l-localname)
2139 (delete-file linkname))) 2139 (delete-file linkname)))
2140 2140
2141 ;; If FILENAME is a Tramp name, use just the localname component. 2141 ;; If FILENAME is a Tramp name, use just the localname component.
2142 (when (tramp-tramp-file-p filename) 2142 (when (tramp-tramp-file-p filename)
2143 (setq filename (tramp-file-name-localname 2143 (setq filename
2144 (tramp-dissect-file-name 2144 (tramp-file-name-localname
2145 (expand-file-name filename))))) 2145 (tramp-dissect-file-name (expand-file-name filename)))))
2146 2146
2147 ;; Right, they are on the same host, regardless of user, method, etc. 2147 ;; Right, they are on the same host, regardless of user, method, etc.
2148 ;; We now make the link on the remote machine. This will occur as the user 2148 ;; We now make the link on the remote machine. This will occur as the user
2149 ;; that FILENAME belongs to. 2149 ;; that FILENAME belongs to.
2150 (zerop 2150 (zerop
4350 (handler tramp-foreign-file-name-handler-alist) 4350 (handler tramp-foreign-file-name-handler-alist)
4351 elt res) 4351 elt res)
4352 ;; When we are not fully sure that filename completion is safe, 4352 ;; When we are not fully sure that filename completion is safe,
4353 ;; we should not return a handler. 4353 ;; we should not return a handler.
4354 (when (or (tramp-file-name-method v) (tramp-file-name-user v) 4354 (when (or (tramp-file-name-method v) (tramp-file-name-user v)
4355 (and (tramp-file-name-host v)
4356 (not (member (tramp-file-name-host v)
4357 (mapcar 'car tramp-methods))))
4355 (not (tramp-completion-mode-p))) 4358 (not (tramp-completion-mode-p)))
4356 (while handler 4359 (while handler
4357 (setq elt (car handler) 4360 (setq elt (car handler)
4358 handler (cdr handler)) 4361 handler (cdr handler))
4359 (when (funcall (car elt) filename) 4362 (when (funcall (car elt) filename)
5114 (defun tramp-maybe-send-script (vec script name) 5117 (defun tramp-maybe-send-script (vec script name)
5115 "Define in remote shell function NAME implemented as SCRIPT. 5118 "Define in remote shell function NAME implemented as SCRIPT.
5116 Only send the definition if it has not already been done." 5119 Only send the definition if it has not already been done."
5117 (let* ((p (tramp-get-connection-process vec)) 5120 (let* ((p (tramp-get-connection-process vec))
5118 (scripts (tramp-get-connection-property p "scripts" nil))) 5121 (scripts (tramp-get-connection-property p "scripts" nil)))
5119 (unless (memq name scripts) 5122 (unless (member name scripts)
5120 (tramp-message vec 5 "Sending script `%s'..." name) 5123 (tramp-message vec 5 "Sending script `%s'..." name)
5121 ;; The script could contain a call of Perl. This is masked with `%s'. 5124 ;; The script could contain a call of Perl. This is masked with `%s'.
5122 (tramp-send-command-and-check 5125 (tramp-send-command-and-check
5123 vec 5126 vec
5124 (format "%s () {\n%s\n}" name 5127 (format "%s () {\n%s\n}" name
7191 ;; original filename if it can't expand anything. Let's just hope 7194 ;; original filename if it can't expand anything. Let's just hope
7192 ;; that this doesn't break anything else. 7195 ;; that this doesn't break anything else.
7193 ;; CCC: This check is now also really awful; we should search all 7196 ;; CCC: This check is now also really awful; we should search all
7194 ;; of the filename format, not just the prefix. 7197 ;; of the filename format, not just the prefix.
7195 (when (string-match "\\[" tramp-prefix-format) 7198 (when (string-match "\\[" tramp-prefix-format)
7196 (defadvice file-expand-wildcards (around tramp-fix activate) 7199 (defadvice file-expand-wildcards
7200 (around tramp-advice-file-expand-wildcards activate)
7197 (let ((name (ad-get-arg 0))) 7201 (let ((name (ad-get-arg 0)))
7198 (if (tramp-tramp-file-p name) 7202 (if (tramp-tramp-file-p name)
7199 ;; If it's a Tramp file, dissect it and look if wildcards 7203 ;; If it's a Tramp file, dissect it and look if wildcards
7200 ;; need to be expanded at all. 7204 ;; need to be expanded at all.
7201 (let ((v (tramp-dissect-file-name name))) 7205 (if (string-match
7202 (if (string-match "[[*?]" (tramp-file-name-localname v)) 7206 "[[*?]"
7203 (let ((res ad-do-it)) 7207 (tramp-file-name-localname (tramp-dissect-file-name name)))
7204 (setq ad-return-value (or res (list name)))) 7208 (setq ad-return-value (or ad-do-it (list name)))
7205 (setq ad-return-value (list name)))) 7209 (setq ad-return-value (list name)))
7206 ;; If it is not a Tramp file, just run the original function. 7210 ;; If it is not a Tramp file, just run the original function.
7207 (let ((res ad-do-it)) 7211 (setq ad-return-value (or ad-do-it (list name))))))
7208 (setq ad-return-value (or res (list name)))))))
7209 (add-hook 'tramp-unload-hook 7212 (add-hook 'tramp-unload-hook
7210 '(lambda () (ad-unadvise 'file-expand-wildcards)))) 7213 '(lambda () (ad-unadvise 'file-expand-wildcards))))
7211 7214
7212 ;; Tramp version is useful in a number of situations. 7215 ;; Tramp version is useful in a number of situations.
7213 7216