diff options
| author | Fabián Ezequiel Gallina | 2012-05-17 00:03:26 -0300 |
|---|---|---|
| committer | Fabián Ezequiel Gallina | 2012-05-17 00:03:26 -0300 |
| commit | 40417cb37ad7b4d088d68773d21e8cc8d6f1a5d3 (patch) | |
| tree | bdf7628b106a4d2ee9d5ba3c88c08ccd56a40ed4 /lisp/progmodes/python.el | |
| parent | fc6c545e4c61b341fd433f994c193ec6f61abbdd (diff) | |
| download | emacs-40417cb37ad7b4d088d68773d21e8cc8d6f1a5d3.tar.gz emacs-40417cb37ad7b4d088d68773d21e8cc8d6f1a5d3.zip | |
Enhancements on `python-shell-calculate-process-environment' and `python-shell-calculate-exec-path'
Removed functions:
+ python-util-merge
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 38 |
1 files changed, 11 insertions, 27 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 05e999a6bef..28b5eeaa33f 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -1231,27 +1231,24 @@ uniqueness for different types of configurations." | |||
| 1231 | 1231 | ||
| 1232 | (defun python-shell-calculate-process-environment () | 1232 | (defun python-shell-calculate-process-environment () |
| 1233 | "Calculate process environment given `python-shell-virtualenv-path'." | 1233 | "Calculate process environment given `python-shell-virtualenv-path'." |
| 1234 | (let ((env (python-util-merge 'list python-shell-process-environment | 1234 | (let ((process-environment (append |
| 1235 | process-environment 'string=)) | 1235 | python-shell-process-environment |
| 1236 | process-environment nil)) | ||
| 1236 | (virtualenv (if python-shell-virtualenv-path | 1237 | (virtualenv (if python-shell-virtualenv-path |
| 1237 | (directory-file-name python-shell-virtualenv-path) | 1238 | (directory-file-name python-shell-virtualenv-path) |
| 1238 | nil))) | 1239 | nil))) |
| 1239 | (if (not virtualenv) | 1240 | (if (not virtualenv) |
| 1240 | env | 1241 | process-environment |
| 1241 | (dolist (envvar env) | 1242 | (setenv "PYTHONHOME" nil) |
| 1242 | (let* ((split (split-string envvar "=" t)) | 1243 | (setenv "PATH" (format "%s/bin%s%s" |
| 1243 | (name (nth 0 split)) | 1244 | virtualenv path-separator (getenv "PATH"))) |
| 1244 | (value (nth 1 split))) | 1245 | (setenv "VIRTUAL_ENV" virtualenv)) |
| 1245 | (when (not (string= name "PYTHONHOME")) | 1246 | process-environment)) |
| 1246 | (when (string= name "PATH") | ||
| 1247 | (setq value (format "%s/bin:%s" virtualenv value))) | ||
| 1248 | (setq env (cons (format "%s=%s" name value) env))))) | ||
| 1249 | (cons (format "VIRTUAL_ENV=%s" virtualenv) env)))) | ||
| 1250 | 1247 | ||
| 1251 | (defun python-shell-calculate-exec-path () | 1248 | (defun python-shell-calculate-exec-path () |
| 1252 | "Calculate exec path given `python-shell-virtualenv-path'." | 1249 | "Calculate exec path given `python-shell-virtualenv-path'." |
| 1253 | (let ((path (python-util-merge 'list python-shell-exec-path | 1250 | (let ((path (append python-shell-exec-path |
| 1254 | exec-path 'string=))) | 1251 | exec-path nil))) |
| 1255 | (if (not python-shell-virtualenv-path) | 1252 | (if (not python-shell-virtualenv-path) |
| 1256 | path | 1253 | path |
| 1257 | (cons (format "%s/bin" | 1254 | (cons (format "%s/bin" |
| @@ -2471,19 +2468,6 @@ The type returned can be 'comment, 'string or 'paren." | |||
| 2471 | 2468 | ||
| 2472 | ;;; Utility functions | 2469 | ;;; Utility functions |
| 2473 | 2470 | ||
| 2474 | ;; Stolen from GNUS | ||
| 2475 | (defun python-util-merge (type list1 list2 pred) | ||
| 2476 | "Destructively merge lists to produce a new one. | ||
| 2477 | Argument TYPE is for compatibility and ignored. LIST1 and LIST2 | ||
| 2478 | are the list to be merged. Ordering of the elements is preserved | ||
| 2479 | according to PRED, a `less-than' predicate on the elements." | ||
| 2480 | (let ((res nil)) | ||
| 2481 | (while (and list1 list2) | ||
| 2482 | (if (funcall pred (car list2) (car list1)) | ||
| 2483 | (push (pop list2) res) | ||
| 2484 | (push (pop list1) res))) | ||
| 2485 | (nconc (nreverse res) list1 list2))) | ||
| 2486 | |||
| 2487 | (defun python-util-position (item seq) | 2471 | (defun python-util-position (item seq) |
| 2488 | "Find the first occurrence of ITEM in SEQ. | 2472 | "Find the first occurrence of ITEM in SEQ. |
| 2489 | Return the index of the matching item, or nil if not found." | 2473 | Return the index of the matching item, or nil if not found." |