diff options
| author | Joakim Verona | 2012-07-31 00:00:41 +0200 |
|---|---|---|
| committer | Joakim Verona | 2012-07-31 00:00:41 +0200 |
| commit | 55fa71b3d9bb8609ca3cbb56f92c776ad8724a69 (patch) | |
| tree | b002fe941cc8636f8bd735717e440014359839dd /lisp/progmodes/python.el | |
| parent | 5fb63197843dcae66f2fe0ddd6f4a9d560e9db2f (diff) | |
| parent | b429a4eee4e09b1ba09e17ced5091d042955d84f (diff) | |
| download | emacs-55fa71b3d9bb8609ca3cbb56f92c776ad8724a69.tar.gz emacs-55fa71b3d9bb8609ca3cbb56f92c776ad8724a69.zip | |
upstream
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 132951aedc8..4617ecc420d 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) |
| @@ -1544,7 +1545,7 @@ variable. | |||
| 1544 | 'python-shell-completion-complete-at-point nil 'local) | 1545 | 'python-shell-completion-complete-at-point nil 'local) |
| 1545 | (add-to-list (make-local-variable 'comint-dynamic-complete-functions) | 1546 | (add-to-list (make-local-variable 'comint-dynamic-complete-functions) |
| 1546 | 'python-shell-completion-complete-at-point) | 1547 | 'python-shell-completion-complete-at-point) |
| 1547 | (define-key inferior-python-mode-map (kbd "<tab>") | 1548 | (define-key inferior-python-mode-map "\t" |
| 1548 | 'python-shell-completion-complete-or-indent) | 1549 | 'python-shell-completion-complete-or-indent) |
| 1549 | (when python-shell-enable-font-lock | 1550 | (when python-shell-enable-font-lock |
| 1550 | (set (make-local-variable 'font-lock-defaults) | 1551 | (set (make-local-variable 'font-lock-defaults) |
| @@ -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) |
| @@ -1945,7 +1948,6 @@ completions on the current context." | |||
| 1945 | 1948 | ||
| 1946 | (defun python-shell-completion-complete-at-point () | 1949 | (defun python-shell-completion-complete-at-point () |
| 1947 | "Perform completion at point in inferior Python process." | 1950 | "Perform completion at point in inferior Python process." |
| 1948 | (interactive) | ||
| 1949 | (and comint-last-prompt-overlay | 1951 | (and comint-last-prompt-overlay |
| 1950 | (> (point-marker) (overlay-end comint-last-prompt-overlay)) | 1952 | (> (point-marker) (overlay-end comint-last-prompt-overlay)) |
| 1951 | (python-shell-completion--do-completion-at-point | 1953 | (python-shell-completion--do-completion-at-point |
| @@ -2060,7 +2062,6 @@ Argument OUTPUT is a string with the output from the comint process." | |||
| 2060 | For this to work the best as possible you should call | 2062 | For this to work the best as possible you should call |
| 2061 | `python-shell-send-buffer' from time to time so context in | 2063 | `python-shell-send-buffer' from time to time so context in |
| 2062 | inferior python process is updated properly." | 2064 | inferior python process is updated properly." |
| 2063 | (interactive) | ||
| 2064 | (let ((process (python-shell-get-process))) | 2065 | (let ((process (python-shell-get-process))) |
| 2065 | (if (not process) | 2066 | (if (not process) |
| 2066 | (error "Completion needs an inferior Python process running") | 2067 | (error "Completion needs an inferior Python process running") |