]> code.delx.au - gnu-emacs/commitdiff
Enhancements on `python-shell-calculate-process-environment' and `python-shell-calcul...
authorFabián Ezequiel Gallina <fgallina@cuca>
Thu, 17 May 2012 03:03:26 +0000 (00:03 -0300)
committerFabián Ezequiel Gallina <fgallina@gnu.org>
Thu, 17 May 2012 03:03:26 +0000 (00:03 -0300)
Removed functions:
 + python-util-merge

lisp/progmodes/python.el

index 05e999a6bef92eebb44e02953e43eed973b75f10..28b5eeaa33ff4b1ef1749d2a64a6b39ae841e359 100644 (file)
@@ -1231,27 +1231,24 @@ uniqueness for different types of configurations."
 
 (defun python-shell-calculate-process-environment ()
   "Calculate process environment given `python-shell-virtualenv-path'."
-  (let ((env (python-util-merge 'list python-shell-process-environment
-                                process-environment 'string=))
+  (let ((process-environment (append
+                              python-shell-process-environment
+                              process-environment nil))
         (virtualenv (if python-shell-virtualenv-path
                         (directory-file-name python-shell-virtualenv-path)
                       nil)))
     (if (not virtualenv)
-        env
-      (dolist (envvar env)
-        (let* ((split (split-string envvar "=" t))
-               (name (nth 0 split))
-               (value (nth 1 split)))
-          (when (not (string= name "PYTHONHOME"))
-            (when (string= name "PATH")
-              (setq value (format "%s/bin:%s" virtualenv value)))
-            (setq env (cons (format "%s=%s" name value) env)))))
-      (cons (format "VIRTUAL_ENV=%s" virtualenv) env))))
+        process-environment
+      (setenv "PYTHONHOME" nil)
+      (setenv "PATH" (format "%s/bin%s%s"
+                             virtualenv path-separator (getenv "PATH")))
+      (setenv "VIRTUAL_ENV" virtualenv))
+    process-environment))
 
 (defun python-shell-calculate-exec-path ()
   "Calculate exec path given `python-shell-virtualenv-path'."
-  (let ((path (python-util-merge 'list python-shell-exec-path
-                                 exec-path 'string=)))
+  (let ((path (append python-shell-exec-path
+                      exec-path nil)))
     (if (not python-shell-virtualenv-path)
         path
       (cons (format "%s/bin"
@@ -2471,19 +2468,6 @@ The type returned can be 'comment, 'string or 'paren."
 \f
 ;;; Utility functions
 
-;; Stolen from GNUS
-(defun python-util-merge (type list1 list2 pred)
-  "Destructively merge lists to produce a new one.
-Argument TYPE is for compatibility and ignored.  LIST1 and LIST2
-are the list to be merged.  Ordering of the elements is preserved
-according to PRED, a `less-than' predicate on the elements."
-  (let ((res nil))
-    (while (and list1 list2)
-      (if (funcall pred (car list2) (car list1))
-          (push (pop list2) res)
-        (push (pop list1) res)))
-    (nconc (nreverse res) list1 list2)))
-
 (defun python-util-position (item seq)
   "Find the first occurrence of ITEM in SEQ.
 Return the index of the matching item, or nil if not found."