comparison lisp/net/tramp.el @ 78887:8faf94b6c420

* net/tramp.el (tramp-completion-mode-p): Rename from `tramp-completion-mode'. Revert logic, check `return', `newline' and such alike. Packages like Icicles tend to use other completion characters but `tab' and `space' only. (top): Require cl.el, when `copy-tree' is not available otherwise. * net/tramp-vc.el (tramp-vc-user-login-name): Get argument by `ad-get-arg'. Use `vc-find-version' instead of `process-file' to check whether we have a new enough vc that doesn't need the defadvice.
author Michael Albinus <michael.albinus@gmx.de>
date Mon, 24 Sep 2007 05:42:34 +0000
parents 939017083e04
children ef0a2673bf5e
comparison
equal deleted inserted replaced
78886:da3f83794d1f 78887:8faf94b6c420
91 (unless (and (fboundp 'base64-encode-region) 91 (unless (and (fboundp 'base64-encode-region)
92 (fboundp 'base64-decode-region)) 92 (fboundp 'base64-decode-region))
93 (require 'base64)) ;for the mimencode methods 93 (require 'base64)) ;for the mimencode methods
94 (require 'shell) 94 (require 'shell)
95 (require 'advice) 95 (require 'advice)
96
97 ;; `copy-tree' is part of subr.el since Emacs 22.
98 (eval-when-compile
99 (unless (functionp 'copy-tree)
100 (require 'cl)))
96 101
97 (autoload 'tramp-uuencode-region "tramp-uu" 102 (autoload 'tramp-uuencode-region "tramp-uu"
98 "Implementation of `uuencode' in Lisp.") 103 "Implementation of `uuencode' in Lisp.")
99 (add-hook 'tramp-unload-hook 104 (add-hook 'tramp-unload-hook
100 '(lambda () 105 '(lambda ()
4237 ,(and (eq inhibit-file-name-operation operation) 4242 ,(and (eq inhibit-file-name-operation operation)
4238 inhibit-file-name-handlers))) 4243 inhibit-file-name-handlers)))
4239 (inhibit-file-name-operation operation)) 4244 (inhibit-file-name-operation operation))
4240 (apply operation args)))) 4245 (apply operation args))))
4241 4246
4242 ;; This function is used from `tramp-completion-file-name-handler' functions 4247 ;; This function is used from `tramp-completion-file-name-handler'
4243 ;; only, if `tramp-completion-mode' is true. But this cannot be checked here 4248 ;; functions only, if `tramp-completion-mode-p' is true. But this
4244 ;; because the check is based on a full filename, not available for all 4249 ;; cannot be checked here because the check is based on a full
4245 ;; basic I/O operations. 4250 ;; filename, not available for all basic I/O operations.
4246 ;;;###autoload 4251 ;;;###autoload
4247 (progn (defun tramp-completion-run-real-handler (operation args) 4252 (progn (defun tramp-completion-run-real-handler (operation args)
4248 "Invoke `tramp-file-name-handler' for OPERATION. 4253 "Invoke `tramp-file-name-handler' for OPERATION.
4249 First arg specifies the OPERATION, second arg is a list of arguments to 4254 First arg specifies the OPERATION, second arg is a list of arguments to
4250 pass to the OPERATION." 4255 pass to the OPERATION."
4355 Falls back to normal file name handler if no tramp file name handler exists." 4360 Falls back to normal file name handler if no tramp file name handler exists."
4356 ;; (setq edebug-trace t) 4361 ;; (setq edebug-trace t)
4357 ;; (edebug-trace "%s" (with-output-to-string (backtrace))) 4362 ;; (edebug-trace "%s" (with-output-to-string (backtrace)))
4358 (save-match-data 4363 (save-match-data
4359 (let* ((filename (apply 'tramp-file-name-for-operation operation args)) 4364 (let* ((filename (apply 'tramp-file-name-for-operation operation args))
4360 (completion (tramp-completion-mode filename)) 4365 (completion (tramp-completion-mode-p filename))
4361 (foreign (tramp-find-foreign-file-name-handler filename))) 4366 (foreign (tramp-find-foreign-file-name-handler filename)))
4362 (with-parsed-tramp-file-name filename nil 4367 (with-parsed-tramp-file-name filename nil
4363 (cond 4368 (cond
4364 ;; When we are in completion mode, some operations shouldn' be 4369 ;; When we are in completion mode, some operations shouldn' be
4365 ;; handled by backend. 4370 ;; handled by backend.
4561 ;; shouldn't have partial tramp file name syntax. Maybe another variable should 4566 ;; shouldn't have partial tramp file name syntax. Maybe another variable should
4562 ;; be introduced overwriting this check in such cases. Or we change tramp 4567 ;; be introduced overwriting this check in such cases. Or we change tramp
4563 ;; file name syntax in order to avoid ambiguities, like in XEmacs ... 4568 ;; file name syntax in order to avoid ambiguities, like in XEmacs ...
4564 ;; In case of non unified file names it can be always true (and wouldn't be 4569 ;; In case of non unified file names it can be always true (and wouldn't be
4565 ;; necessary, because there are different regexp). 4570 ;; necessary, because there are different regexp).
4566 (defun tramp-completion-mode (file) 4571 (defun tramp-completion-mode-p (file)
4567 "Checks whether method / user name / host name completion is active." 4572 "Checks whether method / user name / host name completion is active."
4568 (cond 4573 (cond
4569 (tramp-completion-mode t) 4574 (tramp-completion-mode t)
4570 ((string-match "^/.*:.*:$" file) nil) 4575 ((string-match "^/.*:.*:$" file) nil)
4571 ((string-match 4576 ((string-match
4572 (concat tramp-prefix-regexp 4577 (concat tramp-prefix-regexp
4573 "\\(" tramp-method-regexp "\\)" tramp-postfix-single-method-regexp "$") 4578 "\\(" tramp-method-regexp "\\)" tramp-postfix-single-method-regexp "$")
4574 file) 4579 file)
4575 (member (match-string 1 file) (mapcar 'car tramp-methods))) 4580 (member (match-string 1 file) (mapcar 'car tramp-methods)))
4576 ((or (equal last-input-event 'tab) 4581 ((or
4577 ;; Emacs 4582 ;; Emacs
4578 (and (natnump last-input-event) 4583 (not (memq last-input-event '(return newline)))
4579 (or 4584 (and (natnump last-input-event)
4580 ;; ?\t has event-modifier 'control 4585 (not (char-equal last-input-event ?\n))
4581 (char-equal last-input-event ?\t) 4586 (not (char-equal last-input-event ?\r)))
4582 (and (not (event-modifiers last-input-event)) 4587 ;; XEmacs
4583 (or (char-equal last-input-event ?\?) 4588 (and (featurep 'xemacs)
4584 (char-equal last-input-event ?\ ))))) 4589 ;; `last-input-event' might be nil.
4585 ;; XEmacs 4590 (not (null last-input-event))
4586 (and (featurep 'xemacs) 4591 ;; `last-input-event' may have no character approximation.
4587 ;; `last-input-event' might be nil. 4592 (funcall (symbol-function 'event-to-character) last-input-event)
4588 (not (null last-input-event)) 4593 (not (char-equal
4589 ;; `last-input-event' may have no character approximation. 4594 (funcall (symbol-function 'event-to-character)
4590 (funcall (symbol-function 'event-to-character) last-input-event) 4595 last-input-event) ?\n))
4591 (or 4596 (not (char-equal
4592 ;; ?\t has event-modifier 'control 4597 (funcall (symbol-function 'event-to-character)
4593 (char-equal 4598 last-input-event) ?\r))))
4594 (funcall (symbol-function 'event-to-character)
4595 last-input-event) ?\t)
4596 (and (not (event-modifiers last-input-event))
4597 (or (char-equal
4598 (funcall (symbol-function 'event-to-character)
4599 last-input-event) ?\?)
4600 (char-equal
4601 (funcall (symbol-function 'event-to-character)
4602 last-input-event) ?\ ))))))
4603 t))) 4599 t)))
4604 4600
4605 ;; Method, host name and user name completion. 4601 ;; Method, host name and user name completion.
4606 ;; `tramp-completion-dissect-file-name' returns a list of 4602 ;; `tramp-completion-dissect-file-name' returns a list of
4607 ;; tramp-file-name structures. For all of them we return possible completions. 4603 ;; tramp-file-name structures. For all of them we return possible completions.
7896 ;; name is a Tramp name. 7892 ;; name is a Tramp name.
7897 ;; * Username and hostname completion. 7893 ;; * Username and hostname completion.
7898 ;; ** If `partial-completion-mode' isn't loaded, "/foo:bla" tries to 7894 ;; ** If `partial-completion-mode' isn't loaded, "/foo:bla" tries to
7899 ;; connect to host "blabla" already if that host is unique. No idea 7895 ;; connect to host "blabla" already if that host is unique. No idea
7900 ;; how to suppress. Maybe not an essential problem. 7896 ;; how to suppress. Maybe not an essential problem.
7901 ;; ** Try to avoid usage of `last-input-event' in `tramp-completion-mode'. 7897 ;; ** Try to avoid usage of `last-input-event' in `tramp-completion-mode-p'.
7902 ;; ** Extend `tramp-get-completion-su' for NIS and shadow passwords. 7898 ;; ** Extend `tramp-get-completion-su' for NIS and shadow passwords.
7903 ;; ** Unify `tramp-parse-{rhosts,shosts,sconfig,hosts,passwd,netrc}'. 7899 ;; ** Unify `tramp-parse-{rhosts,shosts,sconfig,hosts,passwd,netrc}'.
7904 ;; Code is nearly identical. 7900 ;; Code is nearly identical.
7905 ;; ** Decide whiche files to take for searching user/host names depending on 7901 ;; ** Decide whiche files to take for searching user/host names depending on
7906 ;; operating system (windows-nt) in `tramp-completion-function-alist'. 7902 ;; operating system (windows-nt) in `tramp-completion-function-alist'.