changeset 72761:a15622a85c05

Quieten the compiler about hippie-expand vars. (python-send-string): Be slightly more careful about adding \n.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sat, 09 Sep 2006 19:42:35 +0000
parents 06f1e0aa1de0
children 298499495f06
files lisp/ChangeLog lisp/progmodes/python.el
diffstat 2 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Sat Sep 09 19:21:31 2006 +0000
+++ b/lisp/ChangeLog	Sat Sep 09 19:42:35 2006 +0000
@@ -1,5 +1,8 @@
 2006-09-09  Stefan Monnier  <monnier@iro.umontreal.ca>
 
+	* progmodes/python.el: Quieten the compiler about hippie-expand vars.
+	(python-send-string): Be slightly more careful about adding \n.
+
 	* startup.el (normal-splash-screen): Don't display the buffer if we'll
 	kill it right away anyway.
 
--- a/lisp/progmodes/python.el	Sat Sep 09 19:21:31 2006 +0000
+++ b/lisp/progmodes/python.el	Sat Sep 09 19:42:35 2006 +0000
@@ -67,7 +67,8 @@
 (eval-when-compile
   (require 'cl)
   (require 'compile)
-  (require 'comint))
+  (require 'comint)
+  (require 'hippie-exp))
 
 (autoload 'comint-mode "comint")
 
@@ -1424,11 +1425,13 @@
   "Evaluate STRING in inferior Python process."
   (interactive "sPython command: ")
   (comint-send-string (python-proc) string)
-  (comint-send-string (python-proc)
-                      ;; If the string is single-line or if it ends with \n,
-                      ;; only add a single \n, otherwise add 2, so as to
-                      ;; make sure we terminate the multiline instruction.
-                      (if (string-match "\n.+\\'" string) "\n\n" "\n")))
+  (unless (string-match "\n\\'" string)
+    ;; Make sure the text is properly LF-terminated.
+    (comint-send-string (python-proc) "\n"))
+  (when (string-match "\n[ \t].*\n?\\'" string)
+    ;; If the string contains a final indented line, add a second newline so
+    ;; as to make sure we terminate the multiline instruction.
+    (comint-send-string (python-proc) "\n")))
 
 (defun python-send-buffer ()
   "Send the current buffer to the inferior Python process."