]> git.eshelyaron.com Git - emacs.git/commitdiff
Extract python-new-pythonpath to handle PYTHONPATH in user code
authorSam Steingold <sds@gnu.org>
Wed, 20 Aug 2014 15:33:10 +0000 (11:33 -0400)
committerSam Steingold <sds@gnu.org>
Wed, 20 Aug 2014 15:33:10 +0000 (11:33 -0400)
* lisp/progmodes/python.el (python-new-pythonpath): Extract from
`python-shell-calculate-process-environment'.

lisp/ChangeLog
lisp/progmodes/python.el

index 78fe9456891c2b53d0d777e8dee0742537dfc437..e1033b1ab8d3d5d36d68b921274ceb7ddaa6d064 100644 (file)
@@ -1,3 +1,8 @@
+2014-08-20  Sam Steingold  <sds@gnu.org>
+
+       * progmodes/python.el (python-new-pythonpath): Extract from
+       `python-shell-calculate-process-environment'.
+
 2014-08-18  Thierry Volpiatto  <thierry.volpiatto@gmail.com>
 
        * emacs-lisp/eldoc.el (eldoc-highlight-function-argument): Add support
index 4ed24a4a4c68e59d051df9ebde0dc2be326ec504..4f645ad64c85609e1a675f62f43f2b2390656318 100644 (file)
@@ -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)