Function: dape--file-name-1

dape--file-name-1 is a natively compiled function defined in dape.el.

Signature

(dape--file-name-1 CONN FILENAME REMOTE-P)

Documentation

Return FILENAME path with prefix substitution applied.

The substitution is configured by CONN or last known connection. If REMOTE-P is non-nil, translate from local to adapter format. Otherwise, translate from adapter to local format. See dape-configs symbols prefix-local prefix-remote.

Source Code

;; Defined in /nix/store/1fiaif8pifqj2jh65rbg3fkhg3i56q42-emacs-packages-deps/share/emacs/site-lisp/elpa/dape-0.27.1/dape.el
(defun dape--file-name-1 (conn filename remote-p)
  "Return FILENAME path with prefix substitution applied.
The substitution is configured by CONN or last known connection.
If REMOTE-P is non-nil, translate from local to adapter format.
Otherwise, translate from adapter to local format.
See `dape-configs' symbols prefix-local prefix-remote."
  (if-let* ((config (dape--config (or conn (dape--live-connection 'last t))))
            (;; Skip if no prefixes configured
             (or (plist-member config 'prefix-local)
                 (plist-member config 'prefix-remote)))
            (;; Is set in `dape--launch-or-attach'
             command-cwd (plist-get config 'command-cwd))
            (expanded-file
             (expand-file-name filename
                               (if remote-p
                                   (tramp-file-local-name command-cwd)
                                 command-cwd)))
            (prefix-local (or (plist-get config 'prefix-local) ""))
            (prefix-remote (or (plist-get config 'prefix-remote) ""))
            (from-prefix (if remote-p prefix-local prefix-remote))
            (to-prefix (if remote-p prefix-remote prefix-local))
            (;; Substitute if there is a match or `from-prefix' is ""
             (string-prefix-p from-prefix expanded-file)))
      (concat to-prefix (string-remove-prefix from-prefix expanded-file))
    filename))