diff options
| author | Fabián Ezequiel Gallina | 2012-07-27 09:38:19 -0300 |
|---|---|---|
| committer | Fabián Ezequiel Gallina | 2012-07-27 09:38:19 -0300 |
| commit | a90dfb95112ebff530ec5c7167c1402b10c2e49b (patch) | |
| tree | ed9838599c8c7c83a30ff389c693c178c0f9a39c /lisp/progmodes/python.el | |
| parent | 1e4be88cc192114695362edcffb7e31efe871983 (diff) | |
| download | emacs-a90dfb95112ebff530ec5c7167c1402b10c2e49b.tar.gz emacs-a90dfb95112ebff530ec5c7167c1402b10c2e49b.zip | |
* lisp/progmodes/python.el (python-mode-map): Added keybinding for
run-python.
(python-shell-make-comint): Fix pop-to-buffer call.
(run-python): Autoload. New arg SHOW.
(python-shell-get-or-create-process): Do not pop python process
buffer.
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 132951aedc8..ab364a5318a 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -250,6 +250,7 @@ | |||
| 250 | (define-key map "\C-c\C-tt" 'python-skeleton-try) | 250 | (define-key map "\C-c\C-tt" 'python-skeleton-try) |
| 251 | (define-key map "\C-c\C-tw" 'python-skeleton-while) | 251 | (define-key map "\C-c\C-tw" 'python-skeleton-while) |
| 252 | ;; Shell interaction | 252 | ;; Shell interaction |
| 253 | (define-key map "\C-c\C-p" 'run-python) | ||
| 253 | (define-key map "\C-c\C-s" 'python-shell-send-string) | 254 | (define-key map "\C-c\C-s" 'python-shell-send-string) |
| 254 | (define-key map "\C-c\C-r" 'python-shell-send-region) | 255 | (define-key map "\C-c\C-r" 'python-shell-send-region) |
| 255 | (define-key map "\C-\M-x" 'python-shell-send-defun) | 256 | (define-key map "\C-\M-x" 'python-shell-send-defun) |
| @@ -1571,30 +1572,33 @@ non-nil the buffer is shown." | |||
| 1571 | (with-current-buffer buffer | 1572 | (with-current-buffer buffer |
| 1572 | (inferior-python-mode) | 1573 | (inferior-python-mode) |
| 1573 | (python-util-clone-local-variables current-buffer)))) | 1574 | (python-util-clone-local-variables current-buffer)))) |
| 1574 | (when pop | 1575 | (and pop (pop-to-buffer proc-buffer-name t)) |
| 1575 | (pop-to-buffer proc-buffer-name)) | ||
| 1576 | proc-buffer-name))) | 1576 | proc-buffer-name))) |
| 1577 | 1577 | ||
| 1578 | (defun run-python (dedicated cmd) | 1578 | ;;;###autoload |
| 1579 | (defun run-python (cmd &optional dedicated show) | ||
| 1579 | "Run an inferior Python process. | 1580 | "Run an inferior Python process. |
| 1580 | Input and output via buffer named after | 1581 | Input and output via buffer named after |
| 1581 | `python-shell-buffer-name'. If there is a process already | 1582 | `python-shell-buffer-name'. If there is a process already |
| 1582 | running in that buffer, just switch to it. | 1583 | running in that buffer, just switch to it. |
| 1583 | With argument, allows you to define DEDICATED, so a dedicated | 1584 | |
| 1584 | process for the current buffer is open, and define CMD so you can | 1585 | With argument, allows you to define CMD so you can edit the |
| 1585 | edit the command used to call the interpreter (default is value | 1586 | command used to call the interpreter and define DEDICATED, so a |
| 1586 | of `python-shell-interpreter' and arguments defined in | 1587 | dedicated process for the current buffer is open. When numeric |
| 1587 | `python-shell-interpreter-args'). Runs the hook | 1588 | prefix arg is other than 0 or 4 do not SHOW. |
| 1588 | `inferior-python-mode-hook' (after the `comint-mode-hook' is | 1589 | |
| 1589 | run). | 1590 | Runs the hook `inferior-python-mode-hook' (after the |
| 1590 | \(Type \\[describe-mode] in the process buffer for a list of commands.)" | 1591 | `comint-mode-hook' is run). \(Type \\[describe-mode] in the |
| 1592 | process buffer for a list of commands.)" | ||
| 1591 | (interactive | 1593 | (interactive |
| 1592 | (if current-prefix-arg | 1594 | (if current-prefix-arg |
| 1593 | (list | 1595 | (list |
| 1596 | (read-string "Run Python: " (python-shell-parse-command)) | ||
| 1594 | (y-or-n-p "Make dedicated process? ") | 1597 | (y-or-n-p "Make dedicated process? ") |
| 1595 | (read-string "Run Python: " (python-shell-parse-command))) | 1598 | (= (prefix-numeric-value current-prefix-arg) 4)) |
| 1596 | (list nil (python-shell-parse-command)))) | 1599 | (list (python-shell-parse-command) nil t))) |
| 1597 | (python-shell-make-comint cmd (python-shell-get-process-name dedicated)) | 1600 | (python-shell-make-comint |
| 1601 | cmd (python-shell-get-process-name dedicated) show) | ||
| 1598 | dedicated) | 1602 | dedicated) |
| 1599 | 1603 | ||
| 1600 | (defun run-python-internal () | 1604 | (defun run-python-internal () |
| @@ -1611,7 +1615,6 @@ with user shells. Runs the hook | |||
| 1611 | `inferior-python-mode-hook' (after the `comint-mode-hook' is | 1615 | `inferior-python-mode-hook' (after the `comint-mode-hook' is |
| 1612 | run). \(Type \\[describe-mode] in the process buffer for a list | 1616 | run). \(Type \\[describe-mode] in the process buffer for a list |
| 1613 | of commands.)" | 1617 | of commands.)" |
| 1614 | (interactive) | ||
| 1615 | (set-process-query-on-exit-flag | 1618 | (set-process-query-on-exit-flag |
| 1616 | (get-buffer-process | 1619 | (get-buffer-process |
| 1617 | (python-shell-make-comint | 1620 | (python-shell-make-comint |
| @@ -1638,7 +1641,7 @@ of commands.)" | |||
| 1638 | (global-proc-buffer-name (format "*%s*" global-proc-name)) | 1641 | (global-proc-buffer-name (format "*%s*" global-proc-name)) |
| 1639 | (dedicated-running (comint-check-proc dedicated-proc-buffer-name)) | 1642 | (dedicated-running (comint-check-proc dedicated-proc-buffer-name)) |
| 1640 | (global-running (comint-check-proc global-proc-buffer-name)) | 1643 | (global-running (comint-check-proc global-proc-buffer-name)) |
| 1641 | (current-prefix-arg 4)) | 1644 | (current-prefix-arg 16)) |
| 1642 | (when (and (not dedicated-running) (not global-running)) | 1645 | (when (and (not dedicated-running) (not global-running)) |
| 1643 | (if (call-interactively 'run-python) | 1646 | (if (call-interactively 'run-python) |
| 1644 | (setq dedicated-running t) | 1647 | (setq dedicated-running t) |