Function: python-shell--convert-file-name-to-send
python-shell--convert-file-name-to-send is a byte-compiled function
defined in python.el.gz.
Signature
(python-shell--convert-file-name-to-send PROCESS FILE-NAME)
Documentation
Convert the FILE-NAME for sending to the inferior Python PROCESS.
If PROCESS is local and FILE-NAME is prefixed with
python-shell-local-prefix, remove the prefix. If PROCESS is remote
and the FILE-NAME is not prefixed, prepend python-shell-local-prefix.
If PROCESS is remote and the file is on the same remote host, remove the
remote prefix. Otherwise, return the file name as is.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/python.el.gz
(defun python-shell--convert-file-name-to-send (process file-name)
"Convert the FILE-NAME for sending to the inferior Python PROCESS.
If PROCESS is local and FILE-NAME is prefixed with
`python-shell-local-prefix', remove the prefix. If PROCESS is remote
and the FILE-NAME is not prefixed, prepend `python-shell-local-prefix'.
If PROCESS is remote and the file is on the same remote host, remove the
remote prefix. Otherwise, return the file name as is."
(when file-name
(let ((process-prefix
(file-remote-p
(with-current-buffer (process-buffer process) default-directory)))
(local-prefix (string-prefix-p python-shell-local-prefix file-name)))
(cond
((and (not process-prefix) local-prefix)
(string-remove-prefix python-shell-local-prefix file-name))
((and process-prefix (not (or local-prefix (file-remote-p file-name))))
(concat python-shell-local-prefix (file-local-name file-name)))
((and process-prefix (string= (file-remote-p file-name) process-prefix))
(file-local-name file-name))
(t file-name)))))