;; non-nil, we must load tramp.el, in order to get the real definition
;; of `tramp-completion-file-name-handler'.
;;;###autoload(defun tramp-completion-file-name-handler (operation &rest args)
-;;;###autoload (if (and (boundp 'non-essential) (symbol-value 'non-essential))
+;;;###autoload (if (tramp-completion-mode-p)
;;;###autoload (apply 'tramp-autoload-file-name-handler operation args)
;;;###autoload (tramp-completion-run-real-handler operation args)))
"Invoke Tramp file name completion handler.
Falls back to normal file name handler if no Tramp file name handler exists."
(let ((fn (assoc operation tramp-completion-file-name-handler-alist)))
- (if (and
- ;; When `tramp-mode' is not enabled, we don't do anything.
- fn tramp-mode (tramp-completion-mode-p)
- ;; For other syntaxes than `sep', the regexp matches many common
- ;; situations where the user doesn't actually want to use Tramp.
- ;; So to avoid autoloading Tramp after typing just "/s", we
- ;; disable this part of the completion, unless the user implicitly
- ;; indicated his interest in using a fancier completion system.
- (or (eq tramp-syntax 'sep)
- (featurep 'tramp) ;; If it's loaded, we may as well use it.
- ;; `partial-completion-mode' is obsoleted with Emacs 24.1.
- (and (boundp 'partial-completion-mode)
- (symbol-value 'partial-completion-mode))
- ;; FIXME: These may have been loaded even if the user never
- ;; intended to use them.
- (featurep 'ido)
- (featurep 'icicles)))
+ (if (and fn tramp-mode (tramp-completion-mode-p))
(save-match-data (apply (cdr fn) args))
(tramp-completion-run-real-handler operation args))))
;; Tramp file name syntax. Maybe another variable should be introduced
;; overwriting this check in such cases. Or we change Tramp file name
;; syntax in order to avoid ambiguities.
-(defun tramp-completion-mode-p ()
+;;;###autoload
+(progn (defun tramp-completion-mode-p ()
"Check, whether method / user name / host name completion is active."
(or
;; Signal from outside. `non-essential' has been introduced in Emacs 24.
(and (boundp 'non-essential) (symbol-value 'non-essential))
- tramp-completion-mode
- (equal last-input-event 'tab)
- (and (natnump last-input-event)
- (or
- ;; ?\t has event-modifier 'control.
- (equal last-input-event ?\t)
- (and (not (event-modifiers last-input-event))
- (or (equal last-input-event ?\?)
- (equal last-input-event ?\ )))))))
+ tramp-completion-mode)))
(defun tramp-connectable-p (filename)
"Check, whether it is possible to connect the remote host w/o side-effects.
(defun tramp-completion-handle-expand-file-name (name &optional dir)
"Like `expand-file-name' for Tramp files."
- (if (tramp-completion-mode-p)
- (progn
- ;; If DIR is not given, use `default-directory' or "/".
- (setq dir (or dir default-directory "/"))
- (cond
- ((file-name-absolute-p name) name)
- ((zerop (length name)) dir)
- (t (concat (file-name-as-directory dir) name))))
-
- (tramp-completion-run-real-handler
- 'expand-file-name (list name dir))))
+ ;; If DIR is not given, use `default-directory' or "/".
+ (setq dir (or dir default-directory "/"))
+ (cond
+ ((file-name-absolute-p name) name)
+ ((zerop (length name)) dir)
+ (t (concat (file-name-as-directory dir) name))))
;; Method, host name and user name completion.
;; `tramp-completion-dissect-file-name' returns a list of
(tramp-connectable-p (expand-file-name filename directory)))
(lambda (x) (funcall predicate (expand-file-name (car x) directory))))))
-;; I misuse a little bit the tramp-file-name structure in order to handle
-;; completion possibilities for partial methods / user names / host names.
-;; Return value is a list of tramp-file-name structures according to possible
-;; completions. If "localname" is non-nil it means there
-;; shouldn't be a completion anymore.
+;; I misuse a little bit the tramp-file-name structure in order to
+;; handle completion possibilities for partial methods / user names /
+;; host names. Return value is a list of tramp-file-name structures
+;; according to possible completions. If "localname" is non-nil it
+;; means there shouldn't be a completion anymore.
;; Expected results: