Function: tramp-make-tramp-file-name

tramp-make-tramp-file-name is a byte-compiled function defined in tramp.el.gz.

Signature

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

Documentation

Construct a Tramp file name from ARGS.

ARGS could have two different signatures. The first one is of type (VEC &optional LOCALNAME HOP). 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. If HOP is nil, the value in VEC is used. If it is a symbol, a null hop will be used. Otherwise, HOP is expected to be a string, which will be used.

The other signature exists for backward compatibility. It has the form (METHOD USER DOMAIN HOST PORT LOCALNAME &optional HOP).

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp.el.gz
(defun tramp-make-tramp-file-name (&rest args)
  "Construct a Tramp file name from ARGS.

ARGS could have two different signatures.  The first one is of
type (VEC &optional LOCALNAME HOP).
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.
If HOP is nil, the value in VEC is used.  If it is a symbol, a
null hop will be used.  Otherwise, HOP is expected to be a
string, which will be used.

The other signature exists for backward compatibility.  It has
the form (METHOD USER DOMAIN HOST PORT LOCALNAME &optional HOP)."
  (let (method user domain host port localname hop)
    (cond
     ((tramp-file-name-p (car args))
      (setq method (tramp-file-name-method (car args))
	    user (tramp-file-name-user (car args))
	    domain (tramp-file-name-domain (car args))
	    host (tramp-file-name-host (car args))
	    port (tramp-file-name-port (car args))
	    localname (tramp-file-name-localname (car args))
	    hop (tramp-file-name-hop (car args)))
      (when (cadr args)
	(setq localname (and (stringp (cadr args)) (cadr args))))
      (when (cl-caddr args)
	(setq hop (and (stringp (cl-caddr args)) (cl-caddr args)))))

     (t (setq method (nth 0 args)
	      user (nth 1 args)
	      domain (nth 2 args)
	      host (nth 3 args)
	      port (nth 4 args)
	      localname (nth 5 args)
	      hop (nth 6 args))))

    ;; Unless `tramp-syntax' is `simplified', we need a method.
    (when (and (not (zerop (length tramp-postfix-method-format)))
	       (zerop (length method)))
      (signal 'wrong-type-argument (list #'stringp method)))
    (concat tramp-prefix-format hop
	    (unless (zerop (length tramp-postfix-method-format))
	      (concat method tramp-postfix-method-format))
	    user
	    (unless (zerop (length domain))
	      (concat tramp-prefix-domain-format domain))
	    (unless (zerop (length 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 (zerop (length port))
	      (concat tramp-prefix-port-format port))
	    tramp-postfix-host-format
	    localname)))