Commits

Anonymous committed 6cb4ea3

python-mode.el and pydoc.el fixes from David A. Panariti <panariti@attbi.com>

Comments (0)

Files changed (3)

+2002-04-20  David A. Panariti  <panariti@attbi.com>
+
+	* python-mode.el (py-execute-region): 
+	Add fix to handle condition where py-which-shell is nil.
+
+	* pydoc.el: Handle new versions of python-mode.el in which
+	py-execute-region return t rather than a buffer[name].  The
+	following changes are executed only when py-execute-region 
+	returns	t.
+	(pydoc-call): Guesses the output buffer name to be the current
+	python process buffer or "*Python Output*".
+	(pydoc-initialize): Sets the output buffer to be the name of the
+	current python process buffer.
+
 2002-04-20  Ville Skyttä  <ville.skytta@xemacs.org>
 
 	* rpm-spec-mode.el: Whitespace cleanup.
 			   " *Python Command*"))
     (if (buffer-live-p (get-buffer input-buf-name))
 	(bury-buffer input-buf-name))
+
+    ;; current vintages of python-mode.el (4.6 at least)
+    ;; no longer return a buffer [name].  We get t from the
+    ;; final kill-buffer instead.  If we see t we use try to
+    ;; guess a good buffer name.
+    (if (eq output-buf-name t)
+	(setq output-buf-name (if async-process
+				  (buffer-name (process-buffer async-process))
+				"*Python Output*")))
+
     (if (or (null output-buf-name)
 	    ;; In earlier versions of python-mode.el, py-execute-string does
 	    ;; not return a buffer name.
 
 pydoc_lisp.pydoc_output_lisp()
 "))
+      ;; current vintages of python-mode.el (4.6 at least)
+      ;; no longer return a buffer [name].  We get t from the
+      ;; final kill-buffer instead.  If we see t we use the
+      ;; python shell's buffer.
+      (if (eq output-buf t)
+	  (setq output-buf 
+		(buffer-name (process-buffer (pydoc-async-output-p)))))
+
       (setq pydoc-alist (pydoc-lisp-read-result output-buf)))
     (if (member pydoc-alist '(nil None Traceback))
 	(progn 
       (setq py-exception-buffer (cons file (current-buffer))))
      (t
       ;; TBD: a horrible hack, buy why create new Custom variables?
-      (let ((cmd (concat py-which-shell
+      (let ((cmd (concat (or py-which-shell 
+			     ;; if py-which-shell isn't set 
+			     ;; (it is buffer-local and defaults to nil)
+			     ;; call py-toggle-shells to set it and
+			     ;; set up all other side effects.
+			     ;; mmm... side effects
+			     (progn
+			       (py-toggle-shells py-default-interpreter)
+			       py-which-shell))
 			 (if (string-equal py-which-bufname "JPython")
 			     " -" ""))))
 	;; otherwise either run it synchronously in a subprocess