Mercurial > emacs
comparison lisp/net/tramp.el @ 108377:7827d5a5c826
* net/tramp-compat.el (byte-compile-not-obsolete-vars): Define if
not bound.
(tramp-compat-copy-file): Add PRESERVE-SELINUX-CONTEXT.
(tramp-compat-funcall): New defmacro.
(tramp-compat-line-beginning-position)
(tramp-compat-line-end-position)
(tramp-compat-temporary-file-directory)
(tramp-compat-make-temp-file, tramp-compat-file-attributes)
(tramp-compat-copy-file, tramp-compat-copy-directory)
(tramp-compat-delete-file, tramp-compat-delete-directory)
(tramp-compat-number-sequence, tramp-compat-process-running-p)
* net/tramp.el (top, with-progress-reporter)
(tramp-rfn-eshadow-setup-minibuffer)
(tramp-rfn-eshadow-update-overlay, tramp-handle-set-file-times)
(tramp-handle-dired-compress-file, tramp-handle-shell-command)
(tramp-completion-mode-p, tramp-check-for-regexp)
(tramp-open-connection-setup-interactive-shell)
(tramp-compute-multi-hops, tramp-read-passwd, tramp-clear-passwd)
(tramp-time-diff, tramp-coding-system-change-eol-conversion)
(tramp-set-process-query-on-exit-flag, tramp-unload-tramp)
* net/tramp-cmds.el (tramp-cleanup-all-connections)
(tramp-reporter-dump-variable, tramp-load-report-modules)
(tramp-append-tramp-buffers)
* net/tramp-gvfs.el (tramp-gvfs-handle-file-selinux-context): Use it.
* net/tramp-imap.el (top): Autoload `epg-make-context'.
author | Michael Albinus <albinus@detlef> |
---|---|
date | Sun, 09 May 2010 21:57:55 +0200 |
parents | 96984953f99e |
children | acaefbe07157 |
comparison
equal
deleted
inserted
replaced
108376:96ef3c75fd61 | 108377:7827d5a5c826 |
---|---|
143 ;; tramp-gvfs needs D-Bus messages. Available since Emacs 23 | 143 ;; tramp-gvfs needs D-Bus messages. Available since Emacs 23 |
144 ;; on some system types. We don't call `dbus-ping', because | 144 ;; on some system types. We don't call `dbus-ping', because |
145 ;; this would load dbus.el. | 145 ;; this would load dbus.el. |
146 (when (and (featurep 'dbusbind) | 146 (when (and (featurep 'dbusbind) |
147 (condition-case nil | 147 (condition-case nil |
148 (funcall (symbol-function 'dbus-get-unique-name) | 148 (tramp-compat-funcall 'dbus-get-unique-name :session) |
149 :session) | |
150 (error nil)) | 149 (error nil)) |
151 (tramp-compat-process-running-p "gvfs-fuse-daemon")) | 150 (tramp-compat-process-running-p "gvfs-fuse-daemon")) |
152 'tramp-gvfs) | 151 'tramp-gvfs) |
153 | 152 |
154 ;; Load gateways. It needs `make-network-process' from Emacs 22. | 153 ;; Load gateways. It needs `make-network-process' from Emacs 22. |
2272 (tramp-message ,vec ,level "%s..." ,message) | 2271 (tramp-message ,vec ,level "%s..." ,message) |
2273 ;; We start a pulsing progress reporter after 3 seconds. Feature | 2272 ;; We start a pulsing progress reporter after 3 seconds. Feature |
2274 ;; introduced in Emacs 24.1. | 2273 ;; introduced in Emacs 24.1. |
2275 (when (<= ,level tramp-verbose) | 2274 (when (<= ,level tramp-verbose) |
2276 (condition-case nil | 2275 (condition-case nil |
2277 (setq pr (funcall (symbol-function 'make-progress-reporter) ,message) | 2276 (setq pr (tramp-compat-funcall 'make-progress-reporter ,message) |
2278 tm (run-at-time 3 0.1 'progress-reporter-update pr)) | 2277 tm (if pr (run-at-time 3 0.1 'progress-reporter-update pr))) |
2279 (error nil))) | 2278 (error nil))) |
2280 (unwind-protect | 2279 (unwind-protect |
2281 ;; Execute the body. | 2280 ;; Execute the body. |
2282 (progn ,@body) | 2281 (progn ,@body) |
2283 ;; Stop progress reporter. | 2282 ;; Stop progress reporter. |
2284 (if tm (cancel-timer tm)) | 2283 (if tm (tramp-compat-funcall 'cancel-timer tm)) |
2285 (tramp-message ,vec ,level "%s...done" ,message)))) | 2284 (tramp-message ,vec ,level "%s...done" ,message)))) |
2286 | 2285 |
2287 (put 'with-progress-reporter 'lisp-indent-function 3) | 2286 (put 'with-progress-reporter 'lisp-indent-function 3) |
2288 (put 'with-progress-reporter 'edebug-form-spec t) | 2287 (put 'with-progress-reporter 'edebug-form-spec t) |
2289 (font-lock-add-keywords 'emacs-lisp-mode '("\\<with-progress-reporter\\>")) | 2288 (font-lock-add-keywords 'emacs-lisp-mode '("\\<with-progress-reporter\\>")) |
2396 "Set up a minibuffer for `file-name-shadow-mode'. | 2395 "Set up a minibuffer for `file-name-shadow-mode'. |
2397 Adds another overlay hiding filename parts according to Tramp's | 2396 Adds another overlay hiding filename parts according to Tramp's |
2398 special handling of `substitute-in-file-name'." | 2397 special handling of `substitute-in-file-name'." |
2399 (when (symbol-value 'minibuffer-completing-file-name) | 2398 (when (symbol-value 'minibuffer-completing-file-name) |
2400 (setq tramp-rfn-eshadow-overlay | 2399 (setq tramp-rfn-eshadow-overlay |
2401 (funcall (symbol-function 'make-overlay) | 2400 (tramp-compat-funcall |
2402 (funcall (symbol-function 'minibuffer-prompt-end)) | 2401 'make-overlay |
2403 (funcall (symbol-function 'minibuffer-prompt-end)))) | 2402 (tramp-compat-funcall 'minibuffer-prompt-end) |
2403 (tramp-compat-funcall 'minibuffer-prompt-end))) | |
2404 ;; Copy rfn-eshadow-overlay properties. | 2404 ;; Copy rfn-eshadow-overlay properties. |
2405 (let ((props (funcall (symbol-function 'overlay-properties) | 2405 (let ((props (tramp-compat-funcall |
2406 (symbol-value 'rfn-eshadow-overlay)))) | 2406 'overlay-properties (symbol-value 'rfn-eshadow-overlay)))) |
2407 (while props | 2407 (while props |
2408 (funcall (symbol-function 'overlay-put) | 2408 (tramp-compat-funcall |
2409 tramp-rfn-eshadow-overlay (pop props) (pop props)))))) | 2409 'overlay-put tramp-rfn-eshadow-overlay (pop props) (pop props)))))) |
2410 | 2410 |
2411 (when (boundp 'rfn-eshadow-setup-minibuffer-hook) | 2411 (when (boundp 'rfn-eshadow-setup-minibuffer-hook) |
2412 (add-hook 'rfn-eshadow-setup-minibuffer-hook | 2412 (add-hook 'rfn-eshadow-setup-minibuffer-hook |
2413 'tramp-rfn-eshadow-setup-minibuffer) | 2413 'tramp-rfn-eshadow-setup-minibuffer) |
2414 (add-hook 'tramp-unload-hook | 2414 (add-hook 'tramp-unload-hook |
2423 "Update `rfn-eshadow-overlay' to cover shadowed part of minibuffer input. | 2423 "Update `rfn-eshadow-overlay' to cover shadowed part of minibuffer input. |
2424 This is intended to be used as a minibuffer `post-command-hook' for | 2424 This is intended to be used as a minibuffer `post-command-hook' for |
2425 `file-name-shadow-mode'; the minibuffer should have already | 2425 `file-name-shadow-mode'; the minibuffer should have already |
2426 been set up by `rfn-eshadow-setup-minibuffer'." | 2426 been set up by `rfn-eshadow-setup-minibuffer'." |
2427 ;; In remote files name, there is a shadowing just for the local part. | 2427 ;; In remote files name, there is a shadowing just for the local part. |
2428 (let ((end (or (funcall (symbol-function 'overlay-end) | 2428 (let ((end (or (tramp-compat-funcall |
2429 (symbol-value 'rfn-eshadow-overlay)) | 2429 'overlay-end (symbol-value 'rfn-eshadow-overlay)) |
2430 (funcall (symbol-function 'minibuffer-prompt-end))))) | 2430 (tramp-compat-funcall 'minibuffer-prompt-end)))) |
2431 (when (file-remote-p (buffer-substring-no-properties end (point-max))) | 2431 (when |
2432 (file-remote-p | |
2433 (tramp-compat-funcall 'buffer-substring-no-properties end (point-max))) | |
2432 (save-excursion | 2434 (save-excursion |
2433 (save-restriction | 2435 (save-restriction |
2434 (narrow-to-region | 2436 (narrow-to-region |
2435 (1+ (or (string-match | 2437 (1+ (or (string-match |
2436 tramp-rfn-eshadow-update-overlay-regexp (buffer-string) end) | 2438 tramp-rfn-eshadow-update-overlay-regexp (buffer-string) end) |
2437 end)) | 2439 end)) |
2438 (point-max)) | 2440 (point-max)) |
2439 (let ((rfn-eshadow-overlay tramp-rfn-eshadow-overlay) | 2441 (let ((rfn-eshadow-overlay tramp-rfn-eshadow-overlay) |
2440 (rfn-eshadow-update-overlay-hook nil)) | 2442 (rfn-eshadow-update-overlay-hook nil)) |
2441 (move-overlay rfn-eshadow-overlay (point-max) (point-max)) | 2443 (tramp-compat-funcall |
2442 (funcall (symbol-function 'rfn-eshadow-update-overlay)))))))) | 2444 'move-overlay rfn-eshadow-overlay (point-max) (point-max)) |
2445 (tramp-compat-funcall 'rfn-eshadow-update-overlay))))))) | |
2443 | 2446 |
2444 (when (boundp 'rfn-eshadow-update-overlay-hook) | 2447 (when (boundp 'rfn-eshadow-update-overlay-hook) |
2445 (add-hook 'rfn-eshadow-update-overlay-hook | 2448 (add-hook 'rfn-eshadow-update-overlay-hook |
2446 'tramp-rfn-eshadow-update-overlay) | 2449 'tramp-rfn-eshadow-update-overlay) |
2447 (add-hook 'tramp-unload-hook | 2450 (add-hook 'tramp-unload-hook |
2987 ;; because we could handle the case when the remote | 2990 ;; because we could handle the case when the remote |
2988 ;; host is located in a different time zone as the | 2991 ;; host is located in a different time zone as the |
2989 ;; local host. | 2992 ;; local host. |
2990 (and (functionp 'subr-arity) | 2993 (and (functionp 'subr-arity) |
2991 (subrp (symbol-function 'format-time-string)) | 2994 (subrp (symbol-function 'format-time-string)) |
2992 (= 3 (cdr (funcall (symbol-function 'subr-arity) | 2995 (= 3 (cdr (tramp-compat-funcall |
2993 (symbol-function | 2996 'subr-arity 'format-time-string)))))) |
2994 'format-time-string))))))) | |
2995 (tramp-send-command-and-check | 2997 (tramp-send-command-and-check |
2996 v (format "%s touch -t %s %s" | 2998 v (format "%s touch -t %s %s" |
2997 (if utc "TZ=UTC; export TZ;" "") | 2999 (if utc "TZ=UTC; export TZ;" "") |
2998 (if utc | 3000 (if utc |
2999 (format-time-string "%Y%m%d%H%M.%S" time t) | 3001 (format-time-string "%Y%m%d%H%M.%S" time t) |
4155 (with-progress-reporter v 0 (format "Uncompressing %s..." file) | 4157 (with-progress-reporter v 0 (format "Uncompressing %s..." file) |
4156 (when (zerop | 4158 (when (zerop |
4157 (tramp-send-command-and-check | 4159 (tramp-send-command-and-check |
4158 v (concat (nth 2 suffix) " " | 4160 v (concat (nth 2 suffix) " " |
4159 (tramp-shell-quote-argument localname)))) | 4161 (tramp-shell-quote-argument localname)))) |
4160 ;; `dired-remove-file' is not defined in XEmacs | 4162 ;; `dired-remove-file' is not defined in XEmacs. |
4161 (funcall (symbol-function 'dired-remove-file) file) | 4163 (tramp-compat-funcall 'dired-remove-file file) |
4162 (string-match (car suffix) file) | 4164 (string-match (car suffix) file) |
4163 (concat (substring file 0 (match-beginning 0)))))) | 4165 (concat (substring file 0 (match-beginning 0)))))) |
4164 (t | 4166 (t |
4165 ;; We don't recognize the file as compressed, so compress it. | 4167 ;; We don't recognize the file as compressed, so compress it. |
4166 ;; Try gzip. | 4168 ;; Try gzip. |
4167 (with-progress-reporter v 0 (format "Compressing %s..." file) | 4169 (with-progress-reporter v 0 (format "Compressing %s..." file) |
4168 (when (zerop | 4170 (when (zerop |
4169 (tramp-send-command-and-check | 4171 (tramp-send-command-and-check |
4170 v (concat "gzip -f " | 4172 v (concat "gzip -f " |
4171 (tramp-shell-quote-argument localname)))) | 4173 (tramp-shell-quote-argument localname)))) |
4172 ;; `dired-remove-file' is not defined in XEmacs | 4174 ;; `dired-remove-file' is not defined in XEmacs. |
4173 (funcall (symbol-function 'dired-remove-file) file) | 4175 (tramp-compat-funcall 'dired-remove-file file) |
4174 (cond ((file-exists-p (concat file ".gz")) | 4176 (cond ((file-exists-p (concat file ".gz")) |
4175 (concat file ".gz")) | 4177 (concat file ".gz")) |
4176 ((file-exists-p (concat file ".z")) | 4178 ((file-exists-p (concat file ".z")) |
4177 (concat file ".z")) | 4179 (concat file ".z")) |
4178 (t nil)))))))))) | 4180 (t nil)))))))))) |
4712 (set-marker (mark-marker) (point) | 4714 (set-marker (mark-marker) (point) |
4713 (current-buffer)))) | 4715 (current-buffer)))) |
4714 ;; There's some output, display it. | 4716 ;; There's some output, display it. |
4715 (when (with-current-buffer output-buffer (> (point-max) (point-min))) | 4717 (when (with-current-buffer output-buffer (> (point-max) (point-min))) |
4716 (if (functionp 'display-message-or-buffer) | 4718 (if (functionp 'display-message-or-buffer) |
4717 (funcall (symbol-function 'display-message-or-buffer) | 4719 (tramp-compat-funcall 'display-message-or-buffer output-buffer) |
4718 output-buffer) | |
4719 (pop-to-buffer output-buffer)))))))) | 4720 (pop-to-buffer output-buffer)))))))) |
4720 | 4721 |
4721 ;; File Editing. | 4722 ;; File Editing. |
4722 | 4723 |
4723 (defvar tramp-handle-file-local-copy-hook nil | 4724 (defvar tramp-handle-file-local-copy-hook nil |
5636 ;; indicated his interest in using a fancier completion system. | 5637 ;; indicated his interest in using a fancier completion system. |
5637 (or (eq tramp-syntax 'sep) | 5638 (or (eq tramp-syntax 'sep) |
5638 (featurep 'tramp) ;; If it's loaded, we may as well use it. | 5639 (featurep 'tramp) ;; If it's loaded, we may as well use it. |
5639 ;; `partial-completion-mode' does not exist in XEmacs. | 5640 ;; `partial-completion-mode' does not exist in XEmacs. |
5640 ;; It is obsoleted with Emacs 24.1. | 5641 ;; It is obsoleted with Emacs 24.1. |
5641 (and (boundp 'partial-completion-mode) partial-completion-mode) | 5642 (and (boundp 'partial-completion-mode) |
5643 (symbol-value 'partial-completion-mode)) | |
5642 ;; FIXME: These may have been loaded even if the user never | 5644 ;; FIXME: These may have been loaded even if the user never |
5643 ;; intended to use them. | 5645 ;; intended to use them. |
5644 (featurep 'ido) | 5646 (featurep 'ido) |
5645 (featurep 'icicles))) | 5647 (featurep 'icicles))) |
5646 (save-match-data (apply (cdr fn) args)) | 5648 (save-match-data (apply (cdr fn) args)) |
5728 ;; XEmacs. | 5730 ;; XEmacs. |
5729 (and (featurep 'xemacs) | 5731 (and (featurep 'xemacs) |
5730 ;; `last-input-event' might be nil. | 5732 ;; `last-input-event' might be nil. |
5731 (not (null last-input-event)) | 5733 (not (null last-input-event)) |
5732 ;; `last-input-event' may have no character approximation. | 5734 ;; `last-input-event' may have no character approximation. |
5733 (funcall (symbol-function 'event-to-character) last-input-event) | 5735 (tramp-compat-funcall 'event-to-character last-input-event) |
5734 (or | 5736 (or |
5735 ;; ?\t has event-modifier 'control. | 5737 ;; ?\t has event-modifier 'control. |
5736 (equal | 5738 (equal |
5737 (funcall (symbol-function 'event-to-character) | 5739 (tramp-compat-funcall 'event-to-character last-input-event) ?\t) |
5738 last-input-event) ?\t) | |
5739 (and (not (event-modifiers last-input-event)) | 5740 (and (not (event-modifiers last-input-event)) |
5740 (or (equal | 5741 (or (equal |
5741 (funcall (symbol-function 'event-to-character) | 5742 (tramp-compat-funcall 'event-to-character last-input-event) |
5742 last-input-event) ?\?) | 5743 ?\?) |
5743 (equal | 5744 (equal |
5744 (funcall (symbol-function 'event-to-character) | 5745 (tramp-compat-funcall 'event-to-character last-input-event) |
5745 last-input-event) ?\ ))))))) | 5746 ?\ ))))))) |
5746 | 5747 |
5747 (defun tramp-connectable-p (filename) | 5748 (defun tramp-connectable-p (filename) |
5748 "Check, whether it is possible to connect the remote host w/o side-effects. | 5749 "Check, whether it is possible to connect the remote host w/o side-effects. |
5749 This is true, if either the remote host is already connected, or if we are | 5750 This is true, if either the remote host is already connected, or if we are |
5750 not in completion mode." | 5751 not in completion mode." |
6775 (goto-char (point-min))))) | 6776 (goto-char (point-min))))) |
6776 | 6777 |
6777 (when (or (not (tramp-get-connection-property proc "check-remote-echo" nil)) | 6778 (when (or (not (tramp-get-connection-property proc "check-remote-echo" nil)) |
6778 ;; Sometimes, the echo string is suppressed on the remote side. | 6779 ;; Sometimes, the echo string is suppressed on the remote side. |
6779 (not (string-equal | 6780 (not (string-equal |
6780 (substring-no-properties | 6781 (tramp-compat-funcall |
6781 tramp-echo-mark-marker | 6782 'substring-no-properties tramp-echo-mark-marker |
6782 0 (min tramp-echo-mark-marker-length (1- (point-max)))) | 6783 0 (min tramp-echo-mark-marker-length (1- (point-max)))) |
6783 (buffer-substring-no-properties | 6784 (tramp-compat-funcall |
6785 'buffer-substring-no-properties | |
6784 1 (min (1+ tramp-echo-mark-marker-length) (point-max)))))) | 6786 1 (min (1+ tramp-echo-mark-marker-length) (point-max)))))) |
6785 ;; No echo to be handled, now we can look for the regexp. | 6787 ;; No echo to be handled, now we can look for the regexp. |
6786 (goto-char (point-min)) | 6788 (goto-char (point-min)) |
6787 (re-search-forward regexp nil t)))) | 6789 (re-search-forward regexp nil t)))) |
6788 | 6790 |
6905 (with-current-buffer (process-buffer proc) | 6907 (with-current-buffer (process-buffer proc) |
6906 (goto-char (point-min)) | 6908 (goto-char (point-min)) |
6907 (if (featurep 'mule) | 6909 (if (featurep 'mule) |
6908 ;; Use MULE to select the right EOL convention for communicating | 6910 ;; Use MULE to select the right EOL convention for communicating |
6909 ;; with the process. | 6911 ;; with the process. |
6910 (let* ((cs (or (funcall (symbol-function 'process-coding-system) proc) | 6912 (let* ((cs (or (tramp-compat-funcall 'process-coding-system proc) |
6911 (cons 'undecided 'undecided))) | 6913 (cons 'undecided 'undecided))) |
6912 cs-decode cs-encode) | 6914 cs-decode cs-encode) |
6913 (when (symbolp cs) (setq cs (cons cs cs))) | 6915 (when (symbolp cs) (setq cs (cons cs cs))) |
6914 (setq cs-decode (car cs)) | 6916 (setq cs-decode (car cs)) |
6915 (setq cs-encode (cdr cs)) | 6917 (setq cs-encode (cdr cs)) |
6918 (setq cs-encode (tramp-coding-system-change-eol-conversion | 6920 (setq cs-encode (tramp-coding-system-change-eol-conversion |
6919 cs-encode 'unix)) | 6921 cs-encode 'unix)) |
6920 (when (search-forward "\r" nil t) | 6922 (when (search-forward "\r" nil t) |
6921 (setq cs-decode (tramp-coding-system-change-eol-conversion | 6923 (setq cs-decode (tramp-coding-system-change-eol-conversion |
6922 cs-decode 'dos))) | 6924 cs-decode 'dos))) |
6923 (funcall (symbol-function 'set-buffer-process-coding-system) | 6925 (tramp-compat-funcall |
6924 cs-decode cs-encode) | 6926 'set-buffer-process-coding-system cs-decode cs-encode) |
6925 (tramp-message | 6927 (tramp-message |
6926 vec 5 "Setting coding system to `%s' and `%s'" cs-decode cs-encode)) | 6928 vec 5 "Setting coding system to `%s' and `%s'" cs-decode cs-encode)) |
6927 ;; Look for ^M and do something useful if found. | 6929 ;; Look for ^M and do something useful if found. |
6928 (when (search-forward "\r" nil t) | 6930 (when (search-forward "\r" nil t) |
6929 ;; We have found a ^M but cannot frob the process coding system | 6931 ;; We have found a ^M but cannot frob the process coding system |
6948 (when (and (stringp old-uname) (not (string-equal old-uname new-uname))) | 6950 (when (and (stringp old-uname) (not (string-equal old-uname new-uname))) |
6949 (with-current-buffer (tramp-get-debug-buffer vec) | 6951 (with-current-buffer (tramp-get-debug-buffer vec) |
6950 ;; Keep the debug buffer. | 6952 ;; Keep the debug buffer. |
6951 (rename-buffer | 6953 (rename-buffer |
6952 (generate-new-buffer-name tramp-temp-buffer-name) 'unique) | 6954 (generate-new-buffer-name tramp-temp-buffer-name) 'unique) |
6953 (funcall (symbol-function 'tramp-cleanup-connection) vec) | 6955 (tramp-compat-funcall 'tramp-cleanup-connection vec) |
6954 (if (= (point-min) (point-max)) | 6956 (if (= (point-min) (point-max)) |
6955 (kill-buffer nil) | 6957 (kill-buffer nil) |
6956 (rename-buffer (tramp-debug-buffer-name vec) 'unique)) | 6958 (rename-buffer (tramp-debug-buffer-name vec) 'unique)) |
6957 ;; We call `tramp-get-buffer' in order to keep the debug buffer. | 6959 ;; We call `tramp-get-buffer' in order to keep the debug buffer. |
6958 (tramp-get-buffer vec) | 6960 (tramp-get-buffer vec) |
7331 ;; Open the gateway connection. | 7333 ;; Open the gateway connection. |
7332 (add-to-list | 7334 (add-to-list |
7333 'target-alist | 7335 'target-alist |
7334 (vector | 7336 (vector |
7335 (tramp-file-name-method hop) (tramp-file-name-user hop) | 7337 (tramp-file-name-method hop) (tramp-file-name-user hop) |
7336 (funcall (symbol-function 'tramp-gw-open-connection) vec gw hop) nil)) | 7338 (tramp-compat-funcall 'tramp-gw-open-connection vec gw hop) nil)) |
7337 ;; For the password prompt, we need the correct values. | 7339 ;; For the password prompt, we need the correct values. |
7338 ;; Therefore, we must remember the gateway vector. But we | 7340 ;; Therefore, we must remember the gateway vector. But we |
7339 ;; cannot do it as connection property, because it shouldn't | 7341 ;; cannot do it as connection property, because it shouldn't |
7340 ;; be persistent. And we have no started process yet either. | 7342 ;; be persistent. And we have no started process yet either. |
7341 (tramp-set-file-property (car target-alist) "" "gateway" hop))) | 7343 (tramp-set-file-property (car target-alist) "" "gateway" hop))) |
8610 (or | 8612 (or |
8611 ;; See if auth-sources contains something useful, if it's bound. | 8613 ;; See if auth-sources contains something useful, if it's bound. |
8612 (and (boundp 'auth-sources) | 8614 (and (boundp 'auth-sources) |
8613 (tramp-get-connection-property v "first-password-request" nil) | 8615 (tramp-get-connection-property v "first-password-request" nil) |
8614 ;; Try with Tramp's current method. | 8616 ;; Try with Tramp's current method. |
8615 (funcall (symbol-function 'auth-source-user-or-password) | 8617 (tramp-compat-funcall |
8616 "password" tramp-current-host tramp-current-method)) | 8618 'auth-source-user-or-password |
8619 "password" tramp-current-host tramp-current-method)) | |
8617 ;; Try the password cache. | 8620 ;; Try the password cache. |
8618 (when (functionp 'password-read) | 8621 (when (functionp 'password-read) |
8619 (unless (tramp-get-connection-property | 8622 (unless (tramp-get-connection-property |
8620 v "first-password-request" nil) | 8623 v "first-password-request" nil) |
8621 (funcall (symbol-function 'password-cache-remove) key)) | 8624 (tramp-compat-funcall 'password-cache-remove key)) |
8622 (let ((password | 8625 (let ((password |
8623 (funcall (symbol-function 'password-read) pw-prompt key))) | 8626 (tramp-compat-funcall 'password-read pw-prompt key))) |
8624 (funcall (symbol-function 'password-cache-add) key password) | 8627 (tramp-compat-funcall 'password-cache-add key password) |
8625 password)) | 8628 password)) |
8626 ;; Else, get the password interactively. | 8629 ;; Else, get the password interactively. |
8627 (read-passwd pw-prompt)) | 8630 (read-passwd pw-prompt)) |
8628 (tramp-set-connection-property v "first-password-request" nil))))) | 8631 (tramp-set-connection-property v "first-password-request" nil))))) |
8629 | 8632 |
8630 (defun tramp-clear-passwd (vec) | 8633 (defun tramp-clear-passwd (vec) |
8631 "Clear password cache for connection related to VEC." | 8634 "Clear password cache for connection related to VEC." |
8632 (when (functionp 'password-cache-remove) | 8635 (tramp-compat-funcall |
8633 (funcall | 8636 'password-cache-remove |
8634 (symbol-function 'password-cache-remove) | 8637 (tramp-make-tramp-file-name |
8635 (tramp-make-tramp-file-name | 8638 (tramp-file-name-method vec) |
8636 (tramp-file-name-method vec) | 8639 (tramp-file-name-user vec) |
8637 (tramp-file-name-user vec) | 8640 (tramp-file-name-host vec) |
8638 (tramp-file-name-host vec) | 8641 ""))) |
8639 "")))) | |
8640 | 8642 |
8641 ;; Snarfed code from time-date.el and parse-time.el | 8643 ;; Snarfed code from time-date.el and parse-time.el |
8642 | 8644 |
8643 (defconst tramp-half-a-year '(241 17024) | 8645 (defconst tramp-half-a-year '(241 17024) |
8644 "Evaluated by \"(days-to-time 183)\".") | 8646 "Evaluated by \"(days-to-time 183)\".") |
8671 "Return the difference between the two times, in seconds. | 8673 "Return the difference between the two times, in seconds. |
8672 T1 and T2 are time values (as returned by `current-time' for example)." | 8674 T1 and T2 are time values (as returned by `current-time' for example)." |
8673 ;; Pacify byte-compiler with `symbol-function'. | 8675 ;; Pacify byte-compiler with `symbol-function'. |
8674 (cond ((and (fboundp 'subtract-time) | 8676 (cond ((and (fboundp 'subtract-time) |
8675 (fboundp 'float-time)) | 8677 (fboundp 'float-time)) |
8676 (funcall (symbol-function 'float-time) | 8678 (tramp-compat-funcall |
8677 (funcall (symbol-function 'subtract-time) t1 t2))) | 8679 'float-time (tramp-compat-funcall 'subtract-time t1 t2))) |
8678 ((and (fboundp 'subtract-time) | 8680 ((and (fboundp 'subtract-time) |
8679 (fboundp 'time-to-seconds)) | 8681 (fboundp 'time-to-seconds)) |
8680 (funcall (symbol-function 'time-to-seconds) | 8682 (tramp-compat-funcall |
8681 (funcall (symbol-function 'subtract-time) t1 t2))) | 8683 'time-to-seconds (tramp-compat-funcall 'subtract-time t1 t2))) |
8682 ((fboundp 'itimer-time-difference) | 8684 ((fboundp 'itimer-time-difference) |
8683 (funcall (symbol-function 'itimer-time-difference) | 8685 (tramp-compat-funcall |
8684 (if (< (length t1) 3) (append t1 '(0)) t1) | 8686 'itimer-time-difference |
8685 (if (< (length t2) 3) (append t2 '(0)) t2))) | 8687 (if (< (length t1) 3) (append t1 '(0)) t1) |
8688 (if (< (length t2) 3) (append t2 '(0)) t2))) | |
8686 (t | 8689 (t |
8687 (let ((time (tramp-time-subtract t1 t2))) | 8690 (let ((time (tramp-time-subtract t1 t2))) |
8688 (+ (* (car time) 65536.0) | 8691 (+ (* (car time) 65536.0) |
8689 (cadr time) | 8692 (cadr time) |
8690 (/ (or (nth 2 time) 0) 1000000.0)))))) | 8693 (/ (or (nth 2 time) 0) 1000000.0)))))) |
8691 | 8694 |
8692 (defun tramp-coding-system-change-eol-conversion (coding-system eol-type) | 8695 (defun tramp-coding-system-change-eol-conversion (coding-system eol-type) |
8693 "Return a coding system like CODING-SYSTEM but with given EOL-TYPE. | 8696 "Return a coding system like CODING-SYSTEM but with given EOL-TYPE. |
8694 EOL-TYPE can be one of `dos', `unix', or `mac'." | 8697 EOL-TYPE can be one of `dos', `unix', or `mac'." |
8695 (cond ((fboundp 'coding-system-change-eol-conversion) | 8698 (cond ((fboundp 'coding-system-change-eol-conversion) |
8696 (funcall (symbol-function 'coding-system-change-eol-conversion) | 8699 (tramp-compat-funcall |
8697 coding-system eol-type)) | 8700 'coding-system-change-eol-conversion coding-system eol-type)) |
8698 ((fboundp 'subsidiary-coding-system) | 8701 ((fboundp 'subsidiary-coding-system) |
8699 (funcall (symbol-function 'subsidiary-coding-system) | 8702 (tramp-compat-funcall |
8700 coding-system | 8703 'subsidiary-coding-system coding-system |
8701 (cond ((eq eol-type 'dos) 'crlf) | 8704 (cond ((eq eol-type 'dos) 'crlf) |
8702 ((eq eol-type 'unix) 'lf) | 8705 ((eq eol-type 'unix) 'lf) |
8703 ((eq eol-type 'mac) 'cr) | 8706 ((eq eol-type 'mac) 'cr) |
8704 (t | 8707 (t |
8705 (error "Unknown EOL-TYPE `%s', must be %s" | 8708 (error "Unknown EOL-TYPE `%s', must be %s" |
8706 eol-type | 8709 eol-type |
8707 "`dos', `unix', or `mac'"))))) | 8710 "`dos', `unix', or `mac'"))))) |
8708 (t (error "Can't change EOL conversion -- is MULE missing?")))) | 8711 (t (error "Can't change EOL conversion -- is MULE missing?")))) |
8709 | 8712 |
8710 (defun tramp-set-process-query-on-exit-flag (process flag) | 8713 (defun tramp-set-process-query-on-exit-flag (process flag) |
8711 "Specify if query is needed for process when Emacs is exited. | 8714 "Specify if query is needed for process when Emacs is exited. |
8712 If the second argument flag is non-nil, Emacs will query the user before | 8715 If the second argument flag is non-nil, Emacs will query the user before |
8713 exiting if process is running." | 8716 exiting if process is running." |
8714 (if (fboundp 'set-process-query-on-exit-flag) | 8717 (if (fboundp 'set-process-query-on-exit-flag) |
8715 (funcall (symbol-function 'set-process-query-on-exit-flag) process flag) | 8718 (tramp-compat-funcall 'set-process-query-on-exit-flag process flag) |
8716 (funcall (symbol-function 'process-kill-without-query) process flag))) | 8719 (tramp-compat-funcall 'process-kill-without-query) process flag)) |
8717 | 8720 |
8718 | 8721 |
8719 ;; ------------------------------------------------------------ | 8722 ;; ------------------------------------------------------------ |
8720 ;; -- Kludges section -- | 8723 ;; -- Kludges section -- |
8721 ;; ------------------------------------------------------------ | 8724 ;; ------------------------------------------------------------ |
8771 "Discard Tramp from loading remote files." | 8774 "Discard Tramp from loading remote files." |
8772 (interactive) | 8775 (interactive) |
8773 ;; When Tramp is not loaded yet, its autoloads are still active. | 8776 ;; When Tramp is not loaded yet, its autoloads are still active. |
8774 (tramp-unload-file-name-handlers) | 8777 (tramp-unload-file-name-handlers) |
8775 ;; ange-ftp settings must be enabled. | 8778 ;; ange-ftp settings must be enabled. |
8776 (when (functionp 'tramp-ftp-enable-ange-ftp) | 8779 (tramp-compat-funcall 'tramp-ftp-enable-ange-ftp) |
8777 (funcall (symbol-function 'tramp-ftp-enable-ange-ftp))) | |
8778 ;; Maybe its not loaded yet. | 8780 ;; Maybe its not loaded yet. |
8779 (condition-case nil | 8781 (condition-case nil |
8780 (unload-feature 'tramp 'force) | 8782 (unload-feature 'tramp 'force) |
8781 (error nil))) | 8783 (error nil))) |
8782 | 8784 |