Function: tramp-handle-expand-file-name

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

Signature

(tramp-handle-expand-file-name NAME &optional DIR)

Documentation

Like expand-file-name for Tramp files.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp.el.gz
(defun tramp-handle-expand-file-name (name &optional dir)
  "Like `expand-file-name' for Tramp files."
  (tramp-skeleton-expand-file-name name dir
    ;; Expand tilde.  Usually, the methods applying this handler do
    ;; not support tilde expansion.  But users could declare a
    ;; respective connection property.  (Bug#53847)
    (when (string-match
	   (rx bos "~" (group (* (not "/"))) (group (* nonl)) eos) localname)
      (let ((uname (match-string 1 localname))
	    (fname (match-string 2 localname))
	    hname)
	(when (tramp-string-empty-or-nil-p uname)
	  (setq uname user))
	(when (setq hname (tramp-get-home-directory v uname))
	  (setq localname (concat hname fname)))))))