Function: tramp-make-tramp-file-name

tramp-make-tramp-file-name is an autoloaded and byte-compiled function defined in tramp.el.gz.

Signature

(tramp-make-tramp-file-name VEC &optional LOCALNAME)

Documentation

Construct a Tramp file name from VEC.

If LOCALNAME is nil, the value in VEC is used. If it is a symbol, a null localname will be used. Otherwise, LOCALNAME is expected to be a string, which will be used.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp.el.gz
;;;###tramp-autoload
(defun tramp-make-tramp-file-name (vec &optional localname)
  "Construct a Tramp file name from VEC.
If LOCALNAME is nil, the value in VEC is used.  If it is a
symbol, a null localname will be used.  Otherwise, LOCALNAME is
expected to be a string, which will be used."
  (let (method user domain host port hop)
    (setq method (tramp-file-name-method vec)
	  user (tramp-file-name-user vec)
	  domain (tramp-file-name-domain vec)
	  host (tramp-file-name-host vec)
	  port (tramp-file-name-port vec)
	  hop (tramp-file-name-hop vec)
	  localname
	  (cond
	   ((null localname) (tramp-file-name-localname vec))
	   ((stringp localname) localname)
	   (t nil)))
    (when hop
      ;; Do not keep the hop for the "archive" method.
      (when (string-equal method tramp-archive-method)
	(setq hop nil))
      ;; Keep hop in file name for completion or when indicated.
      (unless (or minibuffer-completing-file-name tramp-show-ad-hoc-proxies)
	(setq hop nil))
      ;; Assure that the hops are in `tramp-default-proxies-alist'.
      ;; In tramp-archive.el, the slot `hop' is used for the archive
      ;; file name.
      (unless (or minibuffer-completing-file-name
		  (string-equal method tramp-archive-method))
	(tramp-add-hops vec)))

    ;; Unless `tramp-syntax' is `simplified', we need a method.
    (when (and (not (string-empty-p tramp-postfix-method-format))
	       (tramp-string-empty-or-nil-p method))
      (signal 'wrong-type-argument (list #'stringp method)))
    (concat tramp-prefix-format hop
	    (unless (string-empty-p tramp-postfix-method-format)
	      (concat method tramp-postfix-method-format))
	    user
	    (unless (tramp-string-empty-or-nil-p domain)
	      (concat tramp-prefix-domain-format domain))
	    (unless (tramp-string-empty-or-nil-p user)
	      tramp-postfix-user-format)
	    (when host
	      (if (string-match-p tramp-ipv6-regexp host)
		  (concat
		   tramp-prefix-ipv6-format host tramp-postfix-ipv6-format)
		host))
	    (unless (tramp-string-empty-or-nil-p port)
	      (concat tramp-prefix-port-format port))
	    tramp-postfix-host-format
	    localname)))