]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/progmodes/python.el (python-shell-calculate-command): Rename
authorFabián Ezequiel Gallina <galli.87@gmail.com>
Sun, 16 Nov 2014 13:47:14 +0000 (10:47 -0300)
committerFabián Ezequiel Gallina <galli.87@gmail.com>
Sun, 16 Nov 2014 13:47:14 +0000 (10:47 -0300)
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.

* test/automated/python-tests.el
(python-shell-calculate-process-environment-2): Fix test.
(python-shell-calculate-process-environment-1)
(python-shell-calculate-process-environment-3): Cleanup.

lisp/ChangeLog
lisp/progmodes/python.el
test/ChangeLog
test/automated/python-tests.el

index cc749c8755df8cc1b22e51cd05491cf35df6b4e9..dbab5c652a41f7b4f69a743a4138028c76116bed 100644 (file)
@@ -1,3 +1,13 @@
+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
index 7ed218c7c9803129e61b0d17df479df8df77d6fc..f8490254c79a5f1ecd55c051367109299417acd7 100644 (file)
@@ -2084,19 +2084,22 @@ uniqueness for different types of configurations."
             (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
@@ -2114,7 +2117,7 @@ uniqueness for different types of configurations."
                         (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)
@@ -2126,8 +2129,10 @@ uniqueness for different types of configurations."
 
 (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)
@@ -2485,10 +2490,10 @@ process buffer for a list of commands.)"
   (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)
@@ -2512,7 +2517,7 @@ startup."
         (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 ()
index a09c6f78fc7672b2d5176250235d571093edf3fe..e0e04bc262cab30eee4945c601f4f5cc5c228038 100644 (file)
@@ -1,3 +1,10 @@
+2014-11-16  Fabián Ezequiel Gallina  <fgallina@gnu.org>
+
+       * automated/python-tests.el
+       (python-shell-calculate-process-environment-2): Fix test.
+       (python-shell-calculate-process-environment-1)
+       (python-shell-calculate-process-environment-3): Cleanup.
+
 2014-11-16  Fabián Ezequiel Gallina  <fgallina@gnu.org>
 
        * automated/python-tests.el (python-indent-dedenters-8): New test
index f368f995caec7d0a962b0805ae01c222ce071b6d..e4ce5355a841fd54376649612e217532c55f0a9e 100644 (file)
@@ -1836,8 +1836,7 @@ Using `python-shell-interpreter' and
 
 (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)))
@@ -1846,8 +1845,8 @@ Using `python-shell-interpreter' and
 
 (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
@@ -1859,8 +1858,7 @@ Using `python-shell-interpreter' and
 
 (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