Subject: python.el: reuse (sometimes) Python comint buffer

From: Bojan Nikolic <[email-masked]>
Date: Thu, 03 Dec 2009 22:43:41 +0000

Package: emacs,python
Severity: wishlist
Tags: patch

[ resent from
  http://lists.gnu.org/archive/html/emacs-devel/2009-12/msg00188.html ]

Hello,

The run-python function in Emacs 22 python.el used to reuse comint
buffers, which I found very useful. The attached patch I think gets
back close to this behaviour, i.e.:

  If buffer python-buffer is live and "new" hasn't been specified that
  buffer is reused and the new comint process is started
  there. Otherwise it is started in a newly created buffer.

Hope it is useful for others and/or suitable for applying to trunk.

Best,
Bojan

--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1562,7 +1562,10 @@
 	       ;; Suppress use of pager for help output:
 	       (process-connection-type nil))
 	  (apply 'make-comint-in-buffer "Python"
-		 (generate-new-buffer "*Python*")
+		 (if (and (buffer-live-p python-buffer)
+			  (not new))
+		     python-buffer
+		   (generate-new-buffer "*Python*"))
 		 (car cmdlist) nil (cdr cmdlist)))
       (setq-default python-buffer (current-buffer))
       (setq python-buffer (current-buffer))

-- 
Bojan Nikolic          ||          http://www.bnikolic.co.uk