From: Sam Steingold Date: Wed, 20 Aug 2014 15:33:10 +0000 (-0400) Subject: Extract python-new-pythonpath to handle PYTHONPATH in user code X-Git-Tag: emacs-25.0.90~2635^2~679^2~454 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=3f05baa175c2cc9d3e0ae6865dc974d102036d12;p=emacs.git Extract python-new-pythonpath to handle PYTHONPATH in user code * lisp/progmodes/python.el (python-new-pythonpath): Extract from `python-shell-calculate-process-environment'. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 78fe9456891..e1033b1ab8d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2014-08-20 Sam Steingold + + * progmodes/python.el (python-new-pythonpath): Extract from + `python-shell-calculate-process-environment'. + 2014-08-18 Thierry Volpiatto * emacs-lisp/eldoc.el (eldoc-highlight-function-argument): Add support diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 4ed24a4a4c6..4f645ad64c8 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -2069,6 +2069,16 @@ uniqueness for different types of configurations." (executable-find python-shell-interpreter) python-shell-interpreter-args))) +(defun python-new-pythonpath () + "Calculate the new PYTHONPATH value from `python-shell-extra-pythonpaths'." + (let ((pythonpath (getenv "PYTHONPATH")) + (extra (mapconcat 'identity + python-shell-extra-pythonpaths + path-separator))) + (if pythonpath + (concat extra path-separator pythonpath) + extra))) + (defun python-shell-calculate-process-environment () "Calculate process environment given `python-shell-virtualenv-path'." (let ((process-environment (append @@ -2078,13 +2088,7 @@ uniqueness for different types of configurations." (directory-file-name python-shell-virtualenv-path) nil))) (when python-shell-extra-pythonpaths - (setenv "PYTHONPATH" - (format "%s%s%s" - (mapconcat 'identity - python-shell-extra-pythonpaths - path-separator) - path-separator - (or (getenv "PYTHONPATH") "")))) + (setenv "PYTHONPATH" (python-new-pythonpath))) (if (not virtualenv) process-environment (setenv "PYTHONHOME" nil)