+2014-11-16 Fabián Ezequiel Gallina <fgallina@gnu.org>
+
+ * progmodes/python.el (python-shell-calculate-command): Rename
+ from python-shell-parse-command. Cleanup.
+ (run-python, run-python-internal): Use it.
+ (python-shell-calculate-pythonpath): Rename from
+ python-new-pythonpath.
+ (python-shell-calculate-process-environment): Use it.
+ (python-shell-calculate-exec-path): Add comment.
+
2014-11-16 Thierry Banel <tbanelwebmin@free.fr> (tiny change)
* calc/calc-arith.el (math-max-list, math-min-list): Fix bug
(or python-shell-virtualenv-root "")
(mapconcat #'identity python-shell-exec-path "")))))
-(defun python-shell-parse-command () ;FIXME: why name it "parse"?
+(defun python-shell-calculate-command ()
"Calculate the string used to execute the inferior Python process."
- ;; FIXME: process-environment doesn't seem to be used anywhere within
- ;; this let.
- (let ((process-environment (python-shell-calculate-process-environment))
- (exec-path (python-shell-calculate-exec-path)))
+ (let ((exec-path (python-shell-calculate-exec-path)))
+ ;; `exec-path' gets tweaked so that virtualenv's specific
+ ;; `python-shell-interpreter' absolute path can be found by
+ ;; `executable-find'.
(format "%s %s"
- ;; FIXME: Why executable-find?
(executable-find python-shell-interpreter)
python-shell-interpreter-args)))
-(defun python-new-pythonpath ()
- "Calculate the new PYTHONPATH value from `python-shell-extra-pythonpaths'."
+(define-obsolete-function-alias
+ 'python-shell-parse-command
+ #'python-shell-calculate-command "25.1")
+
+(defun python-shell-calculate-pythonpath ()
+ "Calculate the PYTHONPATH using `python-shell-extra-pythonpaths'."
(let ((pythonpath (getenv "PYTHONPATH"))
(extra (mapconcat 'identity
python-shell-extra-pythonpaths
(directory-file-name python-shell-virtualenv-root)
nil)))
(when python-shell-extra-pythonpaths
- (setenv "PYTHONPATH" (python-new-pythonpath)))
+ (setenv "PYTHONPATH" (python-shell-calculate-pythonpath)))
(if (not virtualenv)
process-environment
(setenv "PYTHONHOME" nil)
(defun python-shell-calculate-exec-path ()
"Calculate exec path given `python-shell-virtualenv-root'."
- (let ((path (append python-shell-exec-path
- exec-path nil))) ;FIXME: Why nil?
+ (let ((path (append
+ ;; Use nil as the tail so that the list is a full copy,
+ ;; this is a paranoid safeguard for side-effects.
+ python-shell-exec-path exec-path nil)))
(if (not python-shell-virtualenv-root)
path
(cons (expand-file-name "bin" python-shell-virtualenv-root)
(interactive
(if current-prefix-arg
(list
- (read-shell-command "Run Python: " (python-shell-parse-command))
+ (read-shell-command "Run Python: " (python-shell-calculate-command))
(y-or-n-p "Make dedicated process? ")
(= (prefix-numeric-value current-prefix-arg) 4))
- (list (python-shell-parse-command) nil t)))
+ (list (python-shell-calculate-command) nil t)))
(python-shell-make-comint
cmd (python-shell-get-process-name dedicated) show)
dedicated)
(inferior-python-mode-hook nil))
(get-buffer-process
(python-shell-make-comint
- (python-shell-parse-command)
+ (python-shell-calculate-command)
(python-shell-internal-get-process-name) nil t))))
(defun python-shell-get-buffer ()
(ert-deftest python-shell-calculate-process-environment-1 ()
"Test `python-shell-process-environment' modification."
- (let* ((original-process-environment process-environment)
- (python-shell-process-environment
+ (let* ((python-shell-process-environment
'("TESTVAR1=value1" "TESTVAR2=value2"))
(process-environment
(python-shell-calculate-process-environment)))
(ert-deftest python-shell-calculate-process-environment-2 ()
"Test `python-shell-extra-pythonpaths' modification."
- (let* ((original-process-environment process-environment)
- (original-pythonpath (getenv "PYTHONPATH"))
+ (let* ((process-environment process-environment)
+ (original-pythonpath (setenv "PYTHONPATH" "path3"))
(paths '("path1" "path2"))
(python-shell-extra-pythonpaths paths)
(process-environment
(ert-deftest python-shell-calculate-process-environment-3 ()
"Test `python-shell-virtualenv-path' modification."
- (let* ((original-process-environment process-environment)
- (original-path (or (getenv "PATH") ""))
+ (let* ((original-path (or (getenv "PATH") ""))
(python-shell-virtualenv-path
(directory-file-name user-emacs-directory))
(process-environment