emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] [emacs] 01/01: * lisp/progmodes/python.el (python-shell-ca


From: Fabián Ezequiel Gallina
Subject: [Emacs-diffs] [emacs] 01/01: * lisp/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.
Date: Sun, 16 Nov 2014 13:47:27 +0000

fgallina pushed a commit to branch master
in repository emacs.

commit 6f167f95dc9dae8fc8533ee4d9a497c4f08021b2
Author: Fabián Ezequiel Gallina <address@hidden>
Date:   Sun Nov 16 10:47:14 2014 -0300

    * lisp/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.
    
    * 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                 |   10 ++++++++++
 lisp/progmodes/python.el       |   33 +++++++++++++++++++--------------
 test/ChangeLog                 |    7 +++++++
 test/automated/python-tests.el |   10 ++++------
 4 files changed, 40 insertions(+), 20 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index cc749c8..dbab5c6 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,13 @@
+2014-11-16  Fabián Ezequiel Gallina  <address@hidden>
+
+       * 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 <address@hidden>  (tiny change)
 
        * calc/calc-arith.el (math-max-list, math-min-list): Fix bug
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 7ed218c..f849025 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -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 ()
diff --git a/test/ChangeLog b/test/ChangeLog
index a09c6f7..e0e04bc 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,5 +1,12 @@
 2014-11-16  Fabián Ezequiel Gallina  <address@hidden>
 
+       * 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  <address@hidden>
+
        * automated/python-tests.el (python-indent-dedenters-8): New test
        for Bug#18432.
 
diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el
index f368f99..e4ce535 100644
--- a/test/automated/python-tests.el
+++ b/test/automated/python-tests.el
@@ -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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]