emacs-devel
[Top][All Lists]
Advanced

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

python-mode: reuse existing *Python* buffer


From: Slawomir Nowaczyk
Subject: python-mode: reuse existing *Python* buffer
Date: Thu, 24 Aug 2006 17:41:31 +0200

Hello,

The following patch makes run-python command reuse *Python* buffer if
it exists but the process associated with it has died (unless `new'
argument is t, of course), as opposed to creating *Python<2>* etc.

It also fixes a bug which sometimes caused an error when new Inferior
Python buffer was being created -- the (python-send-string "import
emacs") was being executed in the current buffer, not in the newly
created one.

**********************************************************************

lisp/ChangeLog:

2006-08-24  Slawomir Nowaczyk <address@hidden>

        * progmodes/python.el (run-python): Reuse *Python* buffer when
          old process dies

**********************************************************************

--- EmacsCVS/lisp/progmodes/python.el       2006-08-24 14:01:25.633180800 +0200
+++ Emacs/lisp/progmodes/python.el   2006-08-24 16:57:05.349171200 +0200
@@ -1327,8 +1341,8 @@
              (cons (concat "PYTHONPATH=" data-directory
                            (if path (concat ":" path)))
                    process-environment)))
-       (set-buffer (apply 'make-comint-in-buffer "Python"
-                          (generate-new-buffer "*Python*")
+        (set-buffer (apply 'make-comint-in-buffer "Python"
+                           (if new (generate-new-buffer "*Python*") "*Python*")
                           (car cmdlist) nil (cdr cmdlist)))
        (setq-default python-buffer (current-buffer))
        (setq python-buffer (current-buffer)))
@@ -1342,9 +1356,10 @@
   ;; file.  The code might be inline here, but there's enough that it
   ;; seems worth putting in a separate file, and it's probably cleaner
   ;; to put it in a module.
-  (python-send-string "import emacs")
-  ;; Ensure we're at a prompt before doing anything else.
-  (python-send-receive "print '_emacs_out ()'")
+  (with-current-buffer python-buffer
+    (python-send-string "import emacs")
+    ;; Ensure we're at a prompt before doing anything else.
+    (python-send-receive "print '_emacs_out ()'"))
   ;; Without this, help output goes into the inferior python buffer if
   ;; the process isn't already running.
   (sit-for 1 t)        ;Should we use accept-process-output instead?  --Stef

**********************************************************************

-- 
 Best wishes,
   Slawomir Nowaczyk
     ( address@hidden )

Irreverence is another person's disrespect to your god; there isn't
any word that tells what your disrespect to his god is. -- Mark Twain





reply via email to

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