diff options
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index f946509d6e0..01c17a70f98 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -1546,26 +1546,34 @@ variable. | |||
| 1546 | python-syntax-propertize-function)) | 1546 | python-syntax-propertize-function)) |
| 1547 | (compilation-shell-minor-mode 1)) | 1547 | (compilation-shell-minor-mode 1)) |
| 1548 | 1548 | ||
| 1549 | (defun python-shell-make-comint (cmd proc-name &optional pop) | 1549 | (defun python-shell-make-comint (cmd proc-name &optional pop internal) |
| 1550 | "Create a python shell comint buffer. | 1550 | "Create a python shell comint buffer. |
| 1551 | CMD is the python command to be executed and PROC-NAME is the | 1551 | CMD is the python command to be executed and PROC-NAME is the |
| 1552 | process name the comint buffer will get. After the comint buffer | 1552 | process name the comint buffer will get. After the comint buffer |
| 1553 | is created the `inferior-python-mode' is activated. If POP is | 1553 | is created the `inferior-python-mode' is activated. When |
| 1554 | non-nil the buffer is shown." | 1554 | optional argument POP is non-nil the buffer is shown. When |
| 1555 | optional argument INTERNAL is non-nil this process is run on a | ||
| 1556 | buffer with a name that starts with a space, following the Emacs | ||
| 1557 | convention for temporary/internal buffers, and also makes sure | ||
| 1558 | the user is not queried for confirmation when the process is | ||
| 1559 | killed." | ||
| 1555 | (save-excursion | 1560 | (save-excursion |
| 1556 | (let* ((proc-buffer-name (format "*%s*" proc-name)) | 1561 | (let* ((proc-buffer-name |
| 1562 | (format (if (not internal) "*%s*" " *%s*") proc-name)) | ||
| 1557 | (process-environment (python-shell-calculate-process-environment)) | 1563 | (process-environment (python-shell-calculate-process-environment)) |
| 1558 | (exec-path (python-shell-calculate-exec-path))) | 1564 | (exec-path (python-shell-calculate-exec-path))) |
| 1559 | (when (not (comint-check-proc proc-buffer-name)) | 1565 | (when (not (comint-check-proc proc-buffer-name)) |
| 1560 | (let* ((cmdlist (split-string-and-unquote cmd)) | 1566 | (let* ((cmdlist (split-string-and-unquote cmd)) |
| 1561 | (buffer (apply 'make-comint proc-name (car cmdlist) nil | 1567 | (buffer (apply #'make-comint-in-buffer proc-name proc-buffer-name |
| 1562 | (cdr cmdlist))) | 1568 | (car cmdlist) nil (cdr cmdlist))) |
| 1563 | (current-buffer (current-buffer))) | 1569 | (current-buffer (current-buffer)) |
| 1570 | (process (get-buffer-process buffer))) | ||
| 1564 | (with-current-buffer buffer | 1571 | (with-current-buffer buffer |
| 1565 | (inferior-python-mode) | 1572 | (inferior-python-mode) |
| 1566 | (python-util-clone-local-variables current-buffer)) | 1573 | (python-util-clone-local-variables current-buffer)) |
| 1567 | (accept-process-output (get-buffer-process buffer)))) | 1574 | (accept-process-output process) |
| 1568 | (and pop (pop-to-buffer proc-buffer-name t)) | 1575 | (and pop (pop-to-buffer buffer t)) |
| 1576 | (and internal (set-process-query-on-exit-flag process nil)))) | ||
| 1569 | proc-buffer-name))) | 1577 | proc-buffer-name))) |
| 1570 | 1578 | ||
| 1571 | ;;;###autoload | 1579 | ;;;###autoload |
| @@ -1611,11 +1619,10 @@ are set to nil for these shells, so setup codes are not sent at | |||
| 1611 | startup." | 1619 | startup." |
| 1612 | (let ((python-shell-enable-font-lock nil) | 1620 | (let ((python-shell-enable-font-lock nil) |
| 1613 | (inferior-python-mode-hook nil)) | 1621 | (inferior-python-mode-hook nil)) |
| 1614 | (set-process-query-on-exit-flag | 1622 | (get-buffer-process |
| 1615 | (get-buffer-process | 1623 | (python-shell-make-comint |
| 1616 | (python-shell-make-comint | 1624 | (python-shell-parse-command) |
| 1617 | (python-shell-parse-command) | 1625 | (python-shell-internal-get-process-name) nil t)))) |
| 1618 | (python-shell-internal-get-process-name))) nil))) | ||
| 1619 | 1626 | ||
| 1620 | (defun python-shell-get-process () | 1627 | (defun python-shell-get-process () |
| 1621 | "Get inferior Python process for current buffer and return it." | 1628 | "Get inferior Python process for current buffer and return it." |
| @@ -1662,7 +1669,7 @@ there for compatibility with CEDET.") | |||
| 1662 | (defun python-shell-internal-get-or-create-process () | 1669 | (defun python-shell-internal-get-or-create-process () |
| 1663 | "Get or create an inferior Internal Python process." | 1670 | "Get or create an inferior Internal Python process." |
| 1664 | (let* ((proc-name (python-shell-internal-get-process-name)) | 1671 | (let* ((proc-name (python-shell-internal-get-process-name)) |
| 1665 | (proc-buffer-name (format "*%s*" proc-name))) | 1672 | (proc-buffer-name (format " *%s*" proc-name))) |
| 1666 | (when (not (process-live-p proc-name)) | 1673 | (when (not (process-live-p proc-name)) |
| 1667 | (run-python-internal) | 1674 | (run-python-internal) |
| 1668 | (setq python-shell-internal-buffer proc-buffer-name) | 1675 | (setq python-shell-internal-buffer proc-buffer-name) |