diff options
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 7ed218c7c98..f8490254c79 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -2084,19 +2084,22 @@ uniqueness for different types of configurations." | |||
| 2084 | (or python-shell-virtualenv-root "") | 2084 | (or python-shell-virtualenv-root "") |
| 2085 | (mapconcat #'identity python-shell-exec-path ""))))) | 2085 | (mapconcat #'identity python-shell-exec-path ""))))) |
| 2086 | 2086 | ||
| 2087 | (defun python-shell-parse-command () ;FIXME: why name it "parse"? | 2087 | (defun python-shell-calculate-command () |
| 2088 | "Calculate the string used to execute the inferior Python process." | 2088 | "Calculate the string used to execute the inferior Python process." |
| 2089 | ;; FIXME: process-environment doesn't seem to be used anywhere within | 2089 | (let ((exec-path (python-shell-calculate-exec-path))) |
| 2090 | ;; this let. | 2090 | ;; `exec-path' gets tweaked so that virtualenv's specific |
| 2091 | (let ((process-environment (python-shell-calculate-process-environment)) | 2091 | ;; `python-shell-interpreter' absolute path can be found by |
| 2092 | (exec-path (python-shell-calculate-exec-path))) | 2092 | ;; `executable-find'. |
| 2093 | (format "%s %s" | 2093 | (format "%s %s" |
| 2094 | ;; FIXME: Why executable-find? | ||
| 2095 | (executable-find python-shell-interpreter) | 2094 | (executable-find python-shell-interpreter) |
| 2096 | python-shell-interpreter-args))) | 2095 | python-shell-interpreter-args))) |
| 2097 | 2096 | ||
| 2098 | (defun python-new-pythonpath () | 2097 | (define-obsolete-function-alias |
| 2099 | "Calculate the new PYTHONPATH value from `python-shell-extra-pythonpaths'." | 2098 | 'python-shell-parse-command |
| 2099 | #'python-shell-calculate-command "25.1") | ||
| 2100 | |||
| 2101 | (defun python-shell-calculate-pythonpath () | ||
| 2102 | "Calculate the PYTHONPATH using `python-shell-extra-pythonpaths'." | ||
| 2100 | (let ((pythonpath (getenv "PYTHONPATH")) | 2103 | (let ((pythonpath (getenv "PYTHONPATH")) |
| 2101 | (extra (mapconcat 'identity | 2104 | (extra (mapconcat 'identity |
| 2102 | python-shell-extra-pythonpaths | 2105 | python-shell-extra-pythonpaths |
| @@ -2114,7 +2117,7 @@ uniqueness for different types of configurations." | |||
| 2114 | (directory-file-name python-shell-virtualenv-root) | 2117 | (directory-file-name python-shell-virtualenv-root) |
| 2115 | nil))) | 2118 | nil))) |
| 2116 | (when python-shell-extra-pythonpaths | 2119 | (when python-shell-extra-pythonpaths |
| 2117 | (setenv "PYTHONPATH" (python-new-pythonpath))) | 2120 | (setenv "PYTHONPATH" (python-shell-calculate-pythonpath))) |
| 2118 | (if (not virtualenv) | 2121 | (if (not virtualenv) |
| 2119 | process-environment | 2122 | process-environment |
| 2120 | (setenv "PYTHONHOME" nil) | 2123 | (setenv "PYTHONHOME" nil) |
| @@ -2126,8 +2129,10 @@ uniqueness for different types of configurations." | |||
| 2126 | 2129 | ||
| 2127 | (defun python-shell-calculate-exec-path () | 2130 | (defun python-shell-calculate-exec-path () |
| 2128 | "Calculate exec path given `python-shell-virtualenv-root'." | 2131 | "Calculate exec path given `python-shell-virtualenv-root'." |
| 2129 | (let ((path (append python-shell-exec-path | 2132 | (let ((path (append |
| 2130 | exec-path nil))) ;FIXME: Why nil? | 2133 | ;; Use nil as the tail so that the list is a full copy, |
| 2134 | ;; this is a paranoid safeguard for side-effects. | ||
| 2135 | python-shell-exec-path exec-path nil))) | ||
| 2131 | (if (not python-shell-virtualenv-root) | 2136 | (if (not python-shell-virtualenv-root) |
| 2132 | path | 2137 | path |
| 2133 | (cons (expand-file-name "bin" python-shell-virtualenv-root) | 2138 | (cons (expand-file-name "bin" python-shell-virtualenv-root) |
| @@ -2485,10 +2490,10 @@ process buffer for a list of commands.)" | |||
| 2485 | (interactive | 2490 | (interactive |
| 2486 | (if current-prefix-arg | 2491 | (if current-prefix-arg |
| 2487 | (list | 2492 | (list |
| 2488 | (read-shell-command "Run Python: " (python-shell-parse-command)) | 2493 | (read-shell-command "Run Python: " (python-shell-calculate-command)) |
| 2489 | (y-or-n-p "Make dedicated process? ") | 2494 | (y-or-n-p "Make dedicated process? ") |
| 2490 | (= (prefix-numeric-value current-prefix-arg) 4)) | 2495 | (= (prefix-numeric-value current-prefix-arg) 4)) |
| 2491 | (list (python-shell-parse-command) nil t))) | 2496 | (list (python-shell-calculate-command) nil t))) |
| 2492 | (python-shell-make-comint | 2497 | (python-shell-make-comint |
| 2493 | cmd (python-shell-get-process-name dedicated) show) | 2498 | cmd (python-shell-get-process-name dedicated) show) |
| 2494 | dedicated) | 2499 | dedicated) |
| @@ -2512,7 +2517,7 @@ startup." | |||
| 2512 | (inferior-python-mode-hook nil)) | 2517 | (inferior-python-mode-hook nil)) |
| 2513 | (get-buffer-process | 2518 | (get-buffer-process |
| 2514 | (python-shell-make-comint | 2519 | (python-shell-make-comint |
| 2515 | (python-shell-parse-command) | 2520 | (python-shell-calculate-command) |
| 2516 | (python-shell-internal-get-process-name) nil t)))) | 2521 | (python-shell-internal-get-process-name) nil t)))) |
| 2517 | 2522 | ||
| 2518 | (defun python-shell-get-buffer () | 2523 | (defun python-shell-get-buffer () |