changeset 55240:780b94f913fe

(python-send-command): New fun. (python-send-region, python-load-file): Use it.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Thu, 29 Apr 2004 20:34:11 +0000
parents 1af59a842b93
children cebca4e25fae
files lisp/progmodes/python.el
diffstat 1 files changed, 21 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/progmodes/python.el	Thu Apr 29 19:48:22 2004 +0000
+++ b/lisp/progmodes/python.el	Thu Apr 29 20:34:11 2004 +0000
@@ -1141,6 +1141,14 @@
 print '_emacs_ok'"))
   (unless noshow (pop-to-buffer (setq python-buffer "*Python*"))))
 
+(defun python-send-command (command)
+  "Like `python-send-string' but resets `compilation-minor-mode'."
+  (let ((end (marker-position (process-mark (python-proc)))))
+    (compilation-forget-errors)
+    (python-send-string command)
+    (set-marker compilation-parsing-end end)
+    (setq compilation-last-buffer (current-buffer))))
+
 (defun python-send-region (start end)
   "Send the region to the inferior Python process."
   ;; The region is evaluated from a temporary file.  This avoids
@@ -1170,14 +1178,11 @@
     (write-region start end f t 'nomsg)
     (when python-buffer
       (with-current-buffer python-buffer
-	(let ((end (marker-position (process-mark (python-proc)))))
-	  (set (make-local-variable 'python-orig-start) orig-start)
-	  (set (make-local-variable 'compilation-error-list) nil)
-	  (let ((comint-input-filter-functions
-		 (delete 'python-input-filter comint-input-filter-functions)))
-	    (python-send-string command))
-	  (set-marker compilation-parsing-end end)
-	  (setq compilation-last-buffer (current-buffer)))))))
+	(set (make-local-variable 'python-orig-start) orig-start)
+	(let ((comint-input-filter-functions
+	       ;; Don't reset python-orig-start.
+	       (remq 'python-input-filter comint-input-filter-functions)))
+	  (python-send-command command))))))
 
 (defun python-send-string (string)
   "Evaluate STRING in inferior Python process."
@@ -1242,25 +1247,17 @@
 				   (file-name-nondirectory file-name)))
   (when python-buffer
     (with-current-buffer python-buffer
-      (let ((end (marker-position (process-mark (python-proc)))))
-	(set (make-local-variable 'compilation-error-list) nil)
-	;; (set (make-local-variable 'compilation-old-error-list) nil)
-	(let ((comint-input-filter-functions
-	       (delete 'python-input-filter comint-input-filter-functions)))
-	  (set (make-local-variable 'python-orig-start) nil)
-	  ;; Fixme: I'm not convinced by this logic from python-mode.el.
-	  (python-send-string
-	   (if (string-match "\\.py\\'" file-name)
-	       ;; Fixme: make sure the directory is in the path list
-	       (let ((module (file-name-sans-extension
-			      (file-name-nondirectory file-name))))
-		 (format "\
+      ;; Fixme: I'm not convinced by this logic from python-mode.el.
+      (python-send-command
+       (if (string-match "\\.py\\'" file-name)
+	   ;; Fixme: make sure the directory is in the path list
+	   (let ((module (file-name-sans-extension
+			  (file-name-nondirectory file-name))))
+	     (format "\
 if globals().has_key(%S): reload(%s)
 else: import %s
 " module module module))
-	     (format "execfile('%s')" file-name))))
-	(set-marker compilation-parsing-end end)
-	(setq compilation-last-buffer (current-buffer))))))
+	 (format "execfile('%s')" file-name))))))
 
 ;; Fixme: Should this start a process if there isn't one?  (Unlike cmuscheme.)
 (defun python-proc ()