]> git.eshelyaron.com Git - emacs.git/commitdiff
run-python: Make the buffer running python current
authorTino Calancha <tino.calancha@gmail.com>
Mon, 14 May 2018 16:30:11 +0000 (01:30 +0900)
committerTino Calancha <tino.calancha@gmail.com>
Mon, 14 May 2018 16:30:11 +0000 (01:30 +0900)
* lisp/progmodes/python.el (run-python, python-shell-make-comint):
Make the buffer running the inferior python process the current buffer
(Bug#31398).
* test/lisp/progmodes/python-tests.el (python-tests--bug31398):
Add test.

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

index 32d645cfcc9f8de463ab1b31dc6d7062a2e7070c..a09ca2f2f290c82b9eb69325abaabb2c5047c459 100644 (file)
@@ -2842,10 +2842,12 @@ process buffer for a list of commands.)"
         (y-or-n-p "Make dedicated process? ")
         (= (prefix-numeric-value current-prefix-arg) 4))
      (list (python-shell-calculate-command) nil t)))
-  (get-buffer-process
-   (python-shell-make-comint
-    (or cmd (python-shell-calculate-command))
-    (python-shell-get-process-name dedicated) show)))
+  (let ((buffer
+         (python-shell-make-comint
+          (or cmd (python-shell-calculate-command))
+          (python-shell-get-process-name dedicated) show)))
+    (pop-to-buffer buffer)
+    (get-buffer-process buffer)))
 
 (defun run-python-internal ()
   "Run an inferior Internal Python process.
index 4955da02a25a5fff4619ed08a9bc1642a93dfde5..dd1c45914e2b96845173d9f069433ac8accb89e6 100644 (file)
@@ -5352,6 +5352,14 @@ buffer with overlapping strings."
                     (python-nav-end-of-statement)))
     (should (eolp))))
 
+;; After call `run-python' the buffer running the python process is current.
+(ert-deftest python-tests--bug31398 ()
+  "Test for https://debbugs.gnu.org/31398 ."
+  (let ((buffer (process-buffer (run-python nil nil 'show))))
+    (should (eq buffer (current-buffer)))
+    (pop-to-buffer (other-buffer))
+    (run-python nil nil 'show)
+    (should (eq buffer (current-buffer)))))
 
 (provide 'python-tests)