# HG changeset patch # User Stefan Monnier # Date 1156802307 0 # Node ID b562a18db09491808a5ca5b8df177bc581db4bea # Parent 41f22ed02e757f68cc83d9a07260e05f93c34fb2 (python-send-command): Simplify. (run-python): Don't generate a new buffer unless `new' was specified. Make sure we send `import emacs' to the proper process. diff -r 41f22ed02e75 -r b562a18db094 lisp/ChangeLog --- a/lisp/ChangeLog Mon Aug 28 21:13:34 2006 +0000 +++ b/lisp/ChangeLog Mon Aug 28 21:58:27 2006 +0000 @@ -1,5 +1,9 @@ 2006-08-28 Stefan Monnier + * progmodes/python.el (python-send-command): Simplify. + (run-python): Don't generate a new buffer unless `new' was specified. + Make sure we send `import emacs' to the proper process. + * progmodes/python.el (python-send-command): Don't wait for the command to terminate. Don't fiddle with compilation-parsing-end. diff -r 41f22ed02e75 -r b562a18db094 lisp/progmodes/python.el --- a/lisp/progmodes/python.el Mon Aug 28 21:13:34 2006 +0000 +++ b/lisp/progmodes/python.el Mon Aug 28 21:58:27 2006 +0000 @@ -1330,30 +1330,30 @@ ;; (not a name) in Python buffers from which `run-python' &c is ;; invoked. Would support multiple processes better. (when (or new (not (comint-check-proc python-buffer))) - (save-current-buffer - (let* ((cmdlist (append (python-args-to-list cmd) '("-i"))) - (path (getenv "PYTHONPATH")) - (process-environment ; to import emacs.py - (cons (concat "PYTHONPATH=" data-directory - (if path (concat ":" path))) - process-environment))) - (set-buffer (apply 'make-comint-in-buffer "Python" - (generate-new-buffer "*Python*") - (car cmdlist) nil (cdr cmdlist))) - (setq-default python-buffer (current-buffer)) - (setq python-buffer (current-buffer))) + (with-current-buffer + (let* ((cmdlist (append (python-args-to-list cmd) '("-i"))) + (path (getenv "PYTHONPATH")) + (process-environment ; to import emacs.py + (cons (concat "PYTHONPATH=" data-directory + (if path (concat ":" path))) + process-environment))) + (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)) (accept-process-output (get-buffer-process python-buffer) 5) - (inferior-python-mode))) + (inferior-python-mode) + ;; Load function definitions we need. + ;; Before the preoutput function was used, this was done via -c in + ;; cmdlist, but that loses the banner and doesn't run the startup + ;; 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. + ;; Ensure we're at a prompt before doing anything else. + (python-send-receive "import emacs; print '_emacs_out ()'"))) (if (derived-mode-p 'python-mode) (setq python-buffer (default-value 'python-buffer))) ; buffer-local - ;; Load function definitions we need. - ;; Before the preoutput function was used, this was done via -c in - ;; cmdlist, but that loses the banner and doesn't run the startup - ;; 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. - ;; Ensure we're at a prompt before doing anything else. - (python-send-receive "import emacs; 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 @@ -1369,8 +1369,8 @@ (defun python-send-command (command) "Like `python-send-string' but resets `compilation-shell-minor-mode'. COMMAND should be a single statement." - (assert (not (string-match "\n" command))) - (let ((end (marker-position (process-mark (python-proc))))) + ;; (assert (not (string-match "\n" command))) + ;; (let ((end (marker-position (process-mark (python-proc))))) (with-current-buffer python-buffer (goto-char (point-max))) (compilation-forget-errors) (python-send-string command) @@ -1382,7 +1382,7 @@ ;; (python-send-receive "print '_emacs_out ()'") ;; (with-current-buffer python-buffer ;; (set-marker compilation-parsing-end end)) - )) + ) ;;) (defun python-send-region (start end) "Send the region to the inferior Python process."