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

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

Signature

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

Documentation

Like expand-file-name for Tramp files.

If the localname part of the given file name starts with "/../" then the result will be a local, non-Tramp, file name.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp-sudoedit.el.gz
(defun tramp-sudoedit-handle-expand-file-name (name &optional dir)
  "Like `expand-file-name' for Tramp files.
If the localname part of the given file name starts with \"/../\" then
the result will be a local, non-Tramp, file name."
  (tramp-skeleton-expand-file-name name dir
    ;; Tilde expansion if necessary.  We cannot accept "~/", because
    ;; under sudo "~/" is expanded to the local user home directory
    ;; but to the root home directory.
    (when (tramp-string-empty-or-nil-p localname)
      (setq localname "~"))
    (unless (file-name-absolute-p localname)
      (setq localname (format "~%s/%s" user localname)))
    (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)))))))