diff options
| author | Stefan Monnier | 2006-08-28 21:58:27 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2006-08-28 21:58:27 +0000 |
| commit | e2ac11eba7776e890e2668d7c74e9c0b0b860b8e (patch) | |
| tree | 06fa249c9fa6bd9a7fbb8b1891499142cc70b1d1 /lisp/progmodes/python.el | |
| parent | 6cc91c85a090cbe73d773f69a68d9da7fd2f7a07 (diff) | |
| download | emacs-e2ac11eba7776e890e2668d7c74e9c0b0b860b8e.tar.gz emacs-e2ac11eba7776e890e2668d7c74e9c0b0b860b8e.zip | |
(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.
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 4821376ec7b..ca22e36cb40 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -1330,30 +1330,30 @@ buffer for a list of commands.)" | |||
| 1330 | ;; (not a name) in Python buffers from which `run-python' &c is | 1330 | ;; (not a name) in Python buffers from which `run-python' &c is |
| 1331 | ;; invoked. Would support multiple processes better. | 1331 | ;; invoked. Would support multiple processes better. |
| 1332 | (when (or new (not (comint-check-proc python-buffer))) | 1332 | (when (or new (not (comint-check-proc python-buffer))) |
| 1333 | (save-current-buffer | 1333 | (with-current-buffer |
| 1334 | (let* ((cmdlist (append (python-args-to-list cmd) '("-i"))) | 1334 | (let* ((cmdlist (append (python-args-to-list cmd) '("-i"))) |
| 1335 | (path (getenv "PYTHONPATH")) | 1335 | (path (getenv "PYTHONPATH")) |
| 1336 | (process-environment ; to import emacs.py | 1336 | (process-environment ; to import emacs.py |
| 1337 | (cons (concat "PYTHONPATH=" data-directory | 1337 | (cons (concat "PYTHONPATH=" data-directory |
| 1338 | (if path (concat ":" path))) | 1338 | (if path (concat ":" path))) |
| 1339 | process-environment))) | 1339 | process-environment))) |
| 1340 | (set-buffer (apply 'make-comint-in-buffer "Python" | 1340 | (apply 'make-comint-in-buffer "Python" |
| 1341 | (generate-new-buffer "*Python*") | 1341 | (if new (generate-new-buffer "*Python*") "*Python*") |
| 1342 | (car cmdlist) nil (cdr cmdlist))) | 1342 | (car cmdlist) nil (cdr cmdlist))) |
| 1343 | (setq-default python-buffer (current-buffer)) | 1343 | (setq-default python-buffer (current-buffer)) |
| 1344 | (setq python-buffer (current-buffer))) | 1344 | (setq python-buffer (current-buffer)) |
| 1345 | (accept-process-output (get-buffer-process python-buffer) 5) | 1345 | (accept-process-output (get-buffer-process python-buffer) 5) |
| 1346 | (inferior-python-mode))) | 1346 | (inferior-python-mode) |
| 1347 | ;; Load function definitions we need. | ||
| 1348 | ;; Before the preoutput function was used, this was done via -c in | ||
| 1349 | ;; cmdlist, but that loses the banner and doesn't run the startup | ||
| 1350 | ;; file. The code might be inline here, but there's enough that it | ||
| 1351 | ;; seems worth putting in a separate file, and it's probably cleaner | ||
| 1352 | ;; to put it in a module. | ||
| 1353 | ;; Ensure we're at a prompt before doing anything else. | ||
| 1354 | (python-send-receive "import emacs; print '_emacs_out ()'"))) | ||
| 1347 | (if (derived-mode-p 'python-mode) | 1355 | (if (derived-mode-p 'python-mode) |
| 1348 | (setq python-buffer (default-value 'python-buffer))) ; buffer-local | 1356 | (setq python-buffer (default-value 'python-buffer))) ; buffer-local |
| 1349 | ;; Load function definitions we need. | ||
| 1350 | ;; Before the preoutput function was used, this was done via -c in | ||
| 1351 | ;; cmdlist, but that loses the banner and doesn't run the startup | ||
| 1352 | ;; file. The code might be inline here, but there's enough that it | ||
| 1353 | ;; seems worth putting in a separate file, and it's probably cleaner | ||
| 1354 | ;; to put it in a module. | ||
| 1355 | ;; Ensure we're at a prompt before doing anything else. | ||
| 1356 | (python-send-receive "import emacs; print '_emacs_out ()'") | ||
| 1357 | ;; Without this, help output goes into the inferior python buffer if | 1357 | ;; Without this, help output goes into the inferior python buffer if |
| 1358 | ;; the process isn't already running. | 1358 | ;; the process isn't already running. |
| 1359 | (sit-for 1 t) ;Should we use accept-process-output instead? --Stef | 1359 | (sit-for 1 t) ;Should we use accept-process-output instead? --Stef |
| @@ -1369,8 +1369,8 @@ buffer for a list of commands.)" | |||
| 1369 | (defun python-send-command (command) | 1369 | (defun python-send-command (command) |
| 1370 | "Like `python-send-string' but resets `compilation-shell-minor-mode'. | 1370 | "Like `python-send-string' but resets `compilation-shell-minor-mode'. |
| 1371 | COMMAND should be a single statement." | 1371 | COMMAND should be a single statement." |
| 1372 | (assert (not (string-match "\n" command))) | 1372 | ;; (assert (not (string-match "\n" command))) |
| 1373 | (let ((end (marker-position (process-mark (python-proc))))) | 1373 | ;; (let ((end (marker-position (process-mark (python-proc))))) |
| 1374 | (with-current-buffer python-buffer (goto-char (point-max))) | 1374 | (with-current-buffer python-buffer (goto-char (point-max))) |
| 1375 | (compilation-forget-errors) | 1375 | (compilation-forget-errors) |
| 1376 | (python-send-string command) | 1376 | (python-send-string command) |
| @@ -1382,7 +1382,7 @@ COMMAND should be a single statement." | |||
| 1382 | ;; (python-send-receive "print '_emacs_out ()'") | 1382 | ;; (python-send-receive "print '_emacs_out ()'") |
| 1383 | ;; (with-current-buffer python-buffer | 1383 | ;; (with-current-buffer python-buffer |
| 1384 | ;; (set-marker compilation-parsing-end end)) | 1384 | ;; (set-marker compilation-parsing-end end)) |
| 1385 | )) | 1385 | ) ;;) |
| 1386 | 1386 | ||
| 1387 | (defun python-send-region (start end) | 1387 | (defun python-send-region (start end) |
| 1388 | "Send the region to the inferior Python process." | 1388 | "Send the region to the inferior Python process." |