Function: tramp-completion-handle-expand-file-name

tramp-completion-handle-expand-file-name is a byte-compiled function defined in tramp.el.gz.

Signature

(tramp-completion-handle-expand-file-name FILENAME &optional DIRECTORY)

Documentation

Like expand-file-name for partial Tramp files.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp.el.gz
(defun tramp-completion-handle-expand-file-name (filename &optional directory)
  "Like `expand-file-name' for partial Tramp files."
  ;; We need special handling only when a method is needed.  Then we
  ;; check, whether DIRECTORY is "/method:" or "/[method/".
  (let ((dir (or directory default-directory "/")))
    (cond
     ((file-name-absolute-p filename)
      ;; FILENAME could be like "~/".  We must expand this.
      (tramp-run-real-handler #'expand-file-name (list filename directory)))
     ((and (eq tramp-syntax 'simplified)
           (string-match-p (rx (regexp tramp-postfix-host-regexp) eos) dir))
      (concat dir filename))
     ((string-match-p
       (rx (regexp tramp-prefix-regexp)
	   (* (regexp tramp-remote-file-name-spec-regexp)
	      (regexp tramp-postfix-hop-regexp))
	   (? (regexp tramp-method-regexp) (regexp tramp-postfix-method-regexp)
	      (? (regexp tramp-user-regexp) (regexp tramp-postfix-user-regexp)))
	   eos)
       dir)
      (concat dir filename))
     (t (tramp-run-real-handler #'expand-file-name (list filename directory))))))