Function: tramp-sudoedit-handle-make-symbolic-link

tramp-sudoedit-handle-make-symbolic-link is a byte-compiled function defined in tramp-sudoedit.el.gz.

Signature

(tramp-sudoedit-handle-make-symbolic-link TARGET LINKNAME &optional OK-IF-ALREADY-EXISTS)

Documentation

Like make-symbolic-link for Tramp files.

If TARGET is a non-Tramp file, it is used verbatim as the target of the symlink. If TARGET is a Tramp file, only the localname component is used as the target of the symlink.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp-sudoedit.el.gz
(defun tramp-sudoedit-handle-make-symbolic-link
    (target linkname &optional ok-if-already-exists)
  "Like `make-symbolic-link' for Tramp files.
If TARGET is a non-Tramp file, it is used verbatim as the target
of the symlink.  If TARGET is a Tramp file, only the localname
component is used as the target of the symlink."
  (with-parsed-tramp-file-name (expand-file-name linkname) nil
    ;; If TARGET is a Tramp name, use just the localname component.
    ;; Don't check for a proper method.
    (let ((non-essential t))
      (when (and (tramp-tramp-file-p target)
		 (tramp-file-name-equal-p v (tramp-dissect-file-name target)))
	(setq target (tramp-file-local-name (expand-file-name target))))
      ;; There could be a cyclic link.
      (tramp-flush-file-properties
       v (expand-file-name target (tramp-file-local-name default-directory))))

    ;; If TARGET is still remote, quote it.
    (if (tramp-tramp-file-p target)
	(make-symbolic-link
	 (tramp-compat-file-name-quote target 'top)
	 linkname ok-if-already-exists)

      ;; Do the 'confirm if exists' thing.
      (when (file-exists-p linkname)
	;; What to do?
	(if (or (null ok-if-already-exists) ; not allowed to exist
		(and (numberp ok-if-already-exists)
		     (not
		      (yes-or-no-p
		       (format
			"File %s already exists; make it a link anyway?"
			localname)))))
	    (tramp-error v 'file-already-exists localname)
	  (delete-file linkname)))

      (tramp-flush-file-properties v localname)
      (tramp-sudoedit-send-command
       v "ln" "-sf"
       (tramp-compat-file-name-unquote target)
       (tramp-compat-file-name-unquote localname)))))